There's a few ways to parse events for items:
- The tree's callback
- The tree's handle() method
The callback approach is perhaps easier, saves a little work by avoiding having to derive a class from Fl_Tree and do any event handle() stuff.
So to do that, I expect you'd configure a callback for the tree, and set it up so the callback is invoked whenever there's a click, e.g.
Fl_Tree *tree = new Fl_Tree(..);
tree->callback(MyTree_CB); // tree callback (userdata optional)
tree->when(FL_WHEN_CHANGED|FL_WHEN_RELEASE); // when to invoke callback
tree->item_reselect_mode(FL_TREE_SELECTABLE_ALWAYS); // callback even when reselected
Then in the callback you can get the item clicked with tree->callback_item() , and the reason for the callback with tree->callback_reason() (e.g. 'selected', 'reselected', 'deselected', etc), and then using the item returned by callback_item(), invoke your own custom Fl_Tree_Item's method, e.g. MyTreeItem::my_handle(), so the item can handle click events on it.
From there you should be able to use e.g. Fl::event_x() to determine where on the item the click occurred and if it happened over one of your drawn indicators (e.g. the eyeball icon), and toggle the icon's xpm to affect its state and how it draws, and use Fl::event() to determine if it was a push or release, etc.
I can try to whip up an example and follow up maybe tomorrow, but pretty sure something along those lines should work.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.
[ Direct Link to Message ] |