|
|
On 9/2/21 10:03 PM, Greg Ercolano
wrote:
On 9/2/21 6:38 PM, Bill Spitzak wrote:
It does seem like a bug, calling value() should
not have any side-effects. Especially because the tabs widget
works even if nobody calls value().
Ah, it is weird that just testing with Fl_Tabs::value(void)
can apparently
end up calling hide() and show().. yikes.
That code goes back to 1999 though, so looks like you'd know
for sure:
49a0693962 (Matthias Melcher 2006-08-17 13:43:07 +0000
308) Fl_Widget* Fl_Tabs::value() {
a7904da09a (Bill Spitzak 1999-10-15 09:01:48
+0000 309) Fl_Widget* v = 0;
a7904da09a (Bill Spitzak 1999-10-15 09:01:48
+0000 310) Fl_Widget*const* a = array();
a7904da09a (Bill Spitzak 1999-10-15 09:01:48
+0000 311) for (int i=children(); i--;) {
a7904da09a (Bill Spitzak 1999-10-15 09:01:48
+0000 312) Fl_Widget* o = *a++;
a7904da09a (Bill Spitzak 1999-10-15 09:01:48
+0000 313) if (v) o->hide();
a7904da09a (Bill Spitzak 1999-10-15 09:01:48
+0000 314) else if (o->visible()) v = o;
a7904da09a (Bill Spitzak 1999-10-15 09:01:48
+0000 315) else if (!i)
{o->show(); v = o;}
f9039b2ae2 (Michael R Sweet 1998-10-06 18:21:25
+0000 316) }
f9039b2ae2 (Michael R Sweet 1998-10-06 18:21:25
+0000 317) return v;
f9039b2ae2 (Michael R Sweet 1998-10-06 18:21:25
+0000 318) }
Perhaps that's the cause, because that last line in the loop
that
calls o->show() on the last item seems to be maybe what's
forcing
the last child to be visible if no other one is..
..and by that I mean the loop code in
Fl_Tabs::value(Fl_Widget*) that changes
the selected tab by hide()ing all but the one to be show()n
gets confused when it reaches the last tab and finds it
visible() before it show()s it,
causing the loop to think there was no change when there in
fact was.
It would appear Fl_Widget* value(void) seems to enforce that:
> Not more than one group is visible
> That at least one group is visible (the last, if no
others are)
And that sounds like a good thing to enforce at least
/somewhere/,
as it's hard to imagine the Tabs widget with no group visible,
and/or
more than one group visible at a time.
So perhaps the fix I suggested is the right one, assuming we
want to
leave the value(void) code alone, and the show()
FL_HIDE/FL_SHOW event behavior
is correct.
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/9a3b1031-913e-486b-2bef-c0ff991d4346%40seriss.com.
[ Direct Link to Message ] | |
|
| |