From 28807a3fab6e94d5c1907fdf5417899a6957d8d3 Mon Sep 17 00:00:00 2001 From: Greg Ercolano Date: Mon, 7 May 2018 21:24:06 +0000 Subject: Added convenience method update_menubutton(), which tries to keep the menu synchronized with the Fl_Input field, assuming there's a match. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12908 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- FL/Fl_Input_Choice.H | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'FL/Fl_Input_Choice.H') diff --git a/FL/Fl_Input_Choice.H b/FL/Fl_Input_Choice.H index ab9c63559..80cee90b4 100644 --- a/FL/Fl_Input_Choice.H +++ b/FL/Fl_Input_Choice.H @@ -85,8 +85,11 @@ public: void resize(int X, int Y, int W, int H); /** Adds an item to the menu. + When any item is selected, the Fl_Input_Choice callback() is invoked, + which can do something with the selected item. + You can access the more complex Fl_Menu_Button::add() methods - (setting callbacks, userdata, etc), via menubutton(). Example: + (setting item-specific callbacks, userdata, etc), via menubutton(). Example: \code Fl_Input_Choice *choice = new Fl_Input_Choice(100,10,120,25,"Fonts"); Fl_Menu_Button *mb = choice->menubutton(); // use Fl_Input_Choice's Fl_Menu_Button @@ -143,8 +146,14 @@ public: const char* value() const { return (inp_->value()); } /** Sets the Fl_Input text field's contents to \p val. - Does not affect the menu selection. - \see void value(int val) + + Note it is possible to set the value() to one that is not + in the menubutton's list of choices. + + Setting the value() does NOT affect the menubutton's selection. + If that's needed, call update_menubutton() after setting value(). + + \see void value(int val), update_menubutton() */ void value(const char *val) { inp_->value(val); } @@ -152,6 +161,8 @@ public: to that value. Any previous text is cleared. */ void value(int val); + int update_menubutton(); + /** Returns a pointer to the internal Fl_Menu_Button widget. This can be used to access any of the methods of the menu button, e.g. \code -- cgit v1.2.3