On 10/07/17 03:24,
holm.h...@gmail.com wrote:
>
> Hi,
> Deriving my own class and overloading the handle method is ok, but I run into problems, when to change the selections.
> How to find which item was clicked ?
Quoting the docs:
Fl_Tree_Item * Fl_Tree::callback_item()
http://www.fltk.org/doc-1.3/classFl__Tree.html#ad576e00b3f3c5e2c6dae62fdf513ece2
"""
Gets the item that caused the callback.
The callback() can use this value to see which item changed.
"""
Also, although deprecated:
Fl_Tree_Item * item_clicked ()
http://www.fltk.org/doc-1.3/classFl__Tree.html#a719f3595b8e7a855ed0890cb7e6fdc67
"""
Return the item that was last clicked.
Valid only from within the callback().
Returns
The item clicked, or 0 if none. 0 may also be used to indicate several items were clicked/changed.
*Deprecated: in 1.3.3 ABI – use callback_item() instead.*
"""
And finally, if you want /all/ the selected items (e.g. with multi-mode, the user
can select several items), from the Fl_Tree docs introduction:
"""
You can walk selected items with first_selected_item() and next_selected_item().
"""
http://www.fltk.org/doc-1.3/classFl__Tree.html#a10f283a50a1e627ba2bf972c8b107a87
http://www.fltk.org/doc-1.3/classFl__Tree.html#a63bdc369548cc4287ee633c92ada9af9
> Do I have to check coordinates of mouse / coordinates of each item in the tree ?
No.. please review the docs, as there's many details there, both for Fl_Tree
and Fl_Tree_Item, and the preferences for the tree in Fl_Tree_Prefs:
http://www.fltk.org/doc-1.3/classFl__Tree.html
http://www.fltk.org/doc-1.3/classFl__Tree__Item.html
http://www.fltk.org/doc-1.3/classFl__Tree__Prefs.html
Also, there's /several/ demos, probably more than most widgets, with code examples:
examples/tree-as-container.cxx
examples/tree-custom-draw-items.cxx
examples/tree-custom-sort.cxx
examples/tree-of-tables.cxx
examples/tree-simple.cxx