On 03/29/18 13:08, Greg Ercolano wrote:
> On 03/28/18 18:13, Robin Rowe wrote:
>>
http://seriss.com/people/erco/fltk/Fl_Tree/Fl_Tree/test-simple.cxx
>
> See the red text on the main page for that code:
>
http://seriss.com/people/erco/fltk/Fl_Tree/
>
> Note that Fl_Tree now comes with FLTK, and is no longer a separate project.
>
> In short, use the examples that come with FLTK (in test/ and examples/)
> and not the code at the above page; that code is no longer maintained,
> as it is frozen in place as a historic artifact of the code at the time
> it was first integrated into FLTK in 2009.
Oh, and the specific fix would be to use the examples/tree-simple.cxx
code example that comes in fltk's source directory.
The old code example won't work with the newer Fl_Tree because
that example had to emulate selection behavior that is now default,
making the callback code redundant. (Many features were added since the
2009 code, including shift- and toggle-selection)
Doing so also retriggers the callback, something the old code didn't
do, and didn't have the 'docallback' option flag (which is default 'on').
So to 'fix' the old code example, you'd change these two lines:
tree->deselect_all(); // deselect all items
tree->select(item); // select this one
..so that the new 'docallback' flag is disabled.
So either replace the above with:
tree->deselect_all(NULL, 0); // deselect all: start at root, don't redo callback
tree->select(item, 0); // select this item, don't redo callback
..or just:
tree->select_only(item, 0); // select only: this item, don't redo callback
Note that this just re-implements the already default behavior, so this
would be redundant. But if you wanted to implement your own selection behavior,
that's how to do it without causing reentry.