DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR New]
Link: http://www.fltk.org/str.php?L1709
Version: 2.0-current
I have a menu with two RADIO groups of options, separated by a divider.
The Widget::setonly() function considers ALL members of the parent Group
as part of the RADIO group, even if they are non-contiguous. This causes
both my RADIO groups to act as one, i.e. only one item of both groups can
be set. I.e. setting an item in one group clears not only the other items
in that group, but also *all* the items in the other group.
There seems to be no workaround, because adding a Group to the widget tree
causes a sub-menu to be created.
Only contiguous RADIO buttons should be considered part of a RADIO group.
Any other behavior would likely confuse a user anyway.
The attached patch, which modifies Widget::setonly(), seems to fix this
problem for me. It only clears contiguous RADIO Widgets in the parent,
instead of all RADIO Widgets in the parent.
Link: http://www.fltk.org/str.php?L1709
Version: 2.0-current
1054a1055,1056
> /* [AA BUGFIX] Only consider ADJACENT items as radio group. Menu may
> have multiple radio groups separated by divider */
1057,1059c1059,1069
< for (int i = parent()->children(); i--;) {
< Widget* o = parent()->child(i);
< if (o != this && o->type() == RADIO) o->clear();
---
> Group* g = parent();
> int my_index = g->find( this );
> for( int i = my_index-1; i >= 0; --i ) {
> Widget* c = g->child(i);
> if( RADIO != c->type() ) break;
> c->clear();
> }
> for( int i = my_index+1; i < g->children(); ++i ) {
> Widget* c = g->child(i);
> if( RADIO != c->type() ) break;
> c->clear();
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs