summaryrefslogtreecommitdiff
path: root/src/Fl_Spinner.cxx
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2017-03-10 21:47:08 +0000
committerAlbrecht Schlosser <albrechts.fltk@online.de>2017-03-10 21:47:08 +0000
commit5544404f7a89a3d7e781f5e57d1271076485c91c (patch)
treef1d97d7bf5723b80da09ccdcaf67d1f3ff01b733 /src/Fl_Spinner.cxx
parentb67ba50f147534bcf2beb3305dbcf24e20ff2e72 (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 'src/Fl_Spinner.cxx')
-rw-r--r--src/Fl_Spinner.cxx18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Fl_Spinner.cxx b/src/Fl_Spinner.cxx
index 220ac1698..3ef102a55 100644
--- a/src/Fl_Spinner.cxx
+++ b/src/Fl_Spinner.cxx
@@ -196,6 +196,24 @@ void Fl_Spinner::type(uchar v) {
}
+/**
+ Handles events of Fl_Spinner's embedded input widget.
+
+ Works like Fl_Input::handle() but ignores FL_Up and FL_Down keys
+ so they can be handled by the parent widget (Fl_Spinner).
+*/
+int Fl_Spinner::Fl_Spinner_Input::handle(int event) {
+ if (event == FL_KEYBOARD) {
+ const int key = Fl::event_key();
+ if (key == FL_Up || key == FL_Down) {
+ Fl_Input::handle(FL_UNFOCUS); // sets and potentially clips the input value
+ return 0;
+ }
+ }
+ return Fl_Input::handle(event);
+}
+
+
//
// End of "$Id$".
//