FLTK logo

[master] 2392589 - Return 1 from Fl_Menu_Item::value() for checked items

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 2392589 - Return 1 from Fl_Menu_Item::value() for checked items "Albrecht Schlosser" Sep 18, 2020  
 
commit 2392589f052e29803cf4efc57c02ecfa7a7da2f1
Author:     Albrecht Schlosser <albrechts.fltk@online.de>
AuthorDate: Fri Sep 18 13:39:04 2020 +0200
Commit:     Albrecht Schlosser <albrechts.fltk@online.de>
CommitDate: Fri Sep 18 13:41:16 2020 +0200

    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."

 FL/Fl_Menu_Item.H | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git FL/Fl_Menu_Item.H FL/Fl_Menu_Item.H
index 65be443..f4b7500 100644
--- FL/Fl_Menu_Item.H
+++ FL/Fl_Menu_Item.H
@@ -304,13 +304,13 @@ struct FL_EXPORT Fl_Menu_Item {
   */
   int radio() const {return flags&FL_MENU_RADIO;}
   /** Returns the current value of the check or radio item.
-      This is zero (0) if the menu item is not checked and
-      non-zero otherwise. You 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
-      is FL_MENU_VALUE (4), but may be 1 in a future version.
+      This is zero (0) if the menu item is not checked and non-zero otherwise.
+      \since 1.4.0 this method returns 1 if the item is checked but you
+        should not rely on a particular value, only zero or non-zero.
+      \note The returned value for a checked menu item was FL_MENU_VALUE (4)
+        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
     does not turn off any adjacent radio items like set_only() does.
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.