Overriding TreeView controller


#1

Hi guys I’m trying replace the selection logic for TreeView, what i’m currently doing is triggering selections from the tree item mouse downs, and set the selection states for the tree items trough TreeViewItem setSelected.

However I am having a hard time overriding the original mouse/key behaviour. Even though I turned off intercept mouse clicks (not for children) and disabled keyboard focus, It still sometimes triggers its own key handling instead of mine (for example when I multi select).

How can I remove the original controller from TreeView, without writing my own view.


#2

Are you calling setInterceptsMouseClicks and setWantsKeyboardFocus on the TreeView object directly? In its constructor the TreeView object is passed to a TreeView::ContentComponent object and placed in a Viewport so you want to get this by calling getViewport()->getViewedComponent() on your TreeView and then change the mouse/key behaviour of this object.

Ed


#3

Yeah I have done this aswell and still its eating my key and mouse events somehow.

treeView.getViewport()->getViewedComponent()->setInterceptsMouseClicks(false, true);
treeView.getViewport()->getViewedComponent()->setWantsKeyboardFocus(false);

If i set the mouse intercept for the children to false, nothing responds and it will be quite hard to figure out which tree item has been clicked, since I won’t be able to know anything about the currently visible items etc, which is all dealt with inside the TreeView. It seems like clicking a tree item is manually grabbing focus on the tree view somehow.


#4

I now resorted to manually grabbing the keyboard focus on item clicks… best option I found so far.