ListView does not intercept triple clicks.

I have a listView with both onSelectionChange and onItemsChosen set.

void OnSelectionChange(IEnumerable<object> x) {
            Debug.Log("listView selected: " + listView.selectedIndex);
            Clicked(items[listView.selectedIndex].id);
        }
  listView.onSelectionChange += OnSelectionChange;
  listView.onItemsChosen += OnSelectionChange;

It handles single clicks and double clicks fine, but if I triple-click it passes through to the VisualElecment behind and triggers my MouseDownEvent

overlayLayer.RegisterCallback<MouseDownEvent>(
    e => MouseDown( e.localMousePosition));

Is this expected behaviour or a bug? Currently, I put a button in the listView VisualElement menuItem. This captures all clicks and I then handle all events with the button. This not great because I need to create a Clicked action with the item index and have the button subscribe to it. Since you can not unsubscribe to actions this means I have to clear and reload the UXML on every rebind.

This is not a bug. ListView simply doesn’t handle triple-clicking so it lets the event through.

Not sure what you mean by “menuItem” here.

It should be possible to unsubscribe to UI events. Which callback/action are you referring to here?

I’m curious what overall you’re trying to do. Triple-clicking leaking an event should not be an issue unless you’re competing with ListView for those events. If so, what is the UX pattern you’re going after?

This is in a hex map editor. The hex map is on the bottom and a panel (VisualElement with black background) is on top of it. The panel has a listview in it. I had thought the listview in the panel was intercepting all events. I now have the panel accept mouse down events and just call an empty function with them, so no events go through to the hex map underneath. I am not using any drag type events so mouse up events that don’t end on the element they started on are not a concern.

The list view is acting as a hierarchical tree so I wanted to click on an element and have that open the element if possible, also the elements will be selected. Only one element can be selected at a time and only one element at any level may be open at any time. I used buttons as elements of the list view to get access to the clicked callback for the click event. When the list view is scrolled elements will have to be rebound. I could not see a way to remove a callback attached to the button and replace it with a new one. So I delete the button and make a new call back function that has the correct ID in it when the listview element changes. I am not using the code in my previous post I use this code for bindItem

var regionRecord = items*;*
*// it is not possible to change e.Q<Button>().clicked because it is a action & event*
*// it can only be added to*
*// whole button must be cleared and recreated*
*bindRegionRecord(e, regionRecord);*
*e.Q<VisualElement>(VEIndent).style.width = regionRecord.indent;*
*e.Q<Button>().clicked += () => {Clicked( i); };*
*};```*
*As I learn more about using UI Toolkit I am rewriting things and the hierarchy listview panel is on my list of things to rewrite but it should be using TextMeshPro so I am waiting for that before rewriting it.*

Similar question here, I think is more suitable to call it onSelectionChange does not respond when quick click a listview item more than once

If you add both onSelectionChange and onItemsChosen, it respond when quick click more than once, but the 3rd quick click still got no response, just like thread title said.

It only happens with ListView items clicking.