Return 1 from Fl_Menu_Item::value() for checked items

Previously (FLTK 1.3.x) the return value of a checked menu item
was FL_MENU_VALUE (4) but the docs warned explicitly:

"You should not rely on a particular value, only zero or non-zero."
This commit is contained in:
Albrecht Schlosser 2020-09-18 13:39:04 +02:00
parent 23232d8462
commit 2392589f05

View File

@ -304,13 +304,13 @@ struct FL_EXPORT Fl_Menu_Item {
*/ */
int radio() const {return flags&FL_MENU_RADIO;} int radio() const {return flags&FL_MENU_RADIO;}
/** Returns the current value of the check or radio item. /** Returns the current value of the check or radio item.
This is zero (0) if the menu item is not checked and This is zero (0) if the menu item is not checked and non-zero otherwise.
non-zero otherwise. You should not rely on a particular value, \since 1.4.0 this method returns 1 if the item is checked but you
only zero or non-zero. should not rely on a particular value, only zero or non-zero.
\note The returned value for a checked menu item as of FLTK 1.3.2 \note The returned value for a checked menu item was FL_MENU_VALUE (4)
is FL_MENU_VALUE (4), but may be 1 in a future version. before FLTK 1.4.0.
*/ */
int value() const {return flags&FL_MENU_VALUE;} int value() const {return (flags & FL_MENU_VALUE) ? 1 : 0;}
/** /**
Turns the check or radio item "on" for the menu item. Note that this Turns the check or radio item "on" for the menu item. Note that this
does not turn off any adjacent radio items like set_only() does. does not turn off any adjacent radio items like set_only() does.