diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2017-03-10 21:47:08 +0000 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2017-03-10 21:47:08 +0000 |
| commit | 5544404f7a89a3d7e781f5e57d1271076485c91c (patch) | |
| tree | f1d97d7bf5723b80da09ccdcaf67d1f3ff01b733 /FL/Fl_Spinner.H | |
| parent | b67ba50f147534bcf2beb3305dbcf24e20ff2e72 (diff) | |
Enable Up/Down keys in Fl_Spinner if input has focus (STR #2989).
Previously Up/Down keys worked only if one of the buttons was pressed
before so that it had the focus.
test/valuators.fl: The second Fl_Spinner widget (FL_FLOAT_INPUT) now has
wrap mode disabled whereas the first one (FL_INT_INPUT) uses wrap mode
(default, compatible with FLTK 1.3.x and older).
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12191 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'FL/Fl_Spinner.H')
| -rw-r--r-- | FL/Fl_Spinner.H | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/FL/Fl_Spinner.H b/FL/Fl_Spinner.H index bac216e70..d5d530743 100644 --- a/FL/Fl_Spinner.H +++ b/FL/Fl_Spinner.H @@ -52,7 +52,18 @@ private: protected: - Fl_Input input_; // Input field for the value + // This class works like Fl_Input but ignores FL_Up and FL_Down key + // presses so they are handled by its parent, the Fl_Spinner widget. + // See STR #2989. + + class Fl_Spinner_Input : public Fl_Input { + public: + Fl_Spinner_Input(int X, int Y, int W, int H) + : Fl_Input(X, Y, W, H) {} + int handle(int event); // implemented in src/Fl_Spinner.cxx + }; + + Fl_Spinner_Input input_; // Input field for the value Fl_Repeat_Button up_button_, // Up button down_button_; // Down button @@ -99,15 +110,21 @@ public: /** Sets whether the spinner wraps around at upper and lower bounds. - If wrap mode is on (default) the spinner value is set to the minimum() - or maximum() when the value exceeds the upper or lower bounds, resp., - if the value was changed by one of the buttons. + If wrap mode is on the spinner value is set to the minimum() or + maximum() if the value exceeds the upper or lower bounds, resp., if + it was changed by one of the buttons or the FL_Up or FL_Down keys. - If wrap mode is off, the spinner value stops at the upper and lower bounds. - \see minimum(), maximum() + The spinner stops at the upper and lower bounds if wrap mode is off. + + The default wrap mode is on for backwards compatibility with + FLTK 1.3.x and older versions. - \note This does not apply to the input field. The input value is always - clipped to the allowed range as if wrap mode was off. + \note Wrap mode does not apply to the input field if the input value + is edited directly as a number. The input value is always + clipped to the allowed range as if wrap mode was off when the + input field is left (i.e. loses focus). + + \see minimum(), maximum() \param[in] set non-zero sets wrap mode, zero resets wrap mode |
