summaryrefslogtreecommitdiff
path: root/src/Fl.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Fl.cxx')
-rw-r--r--src/Fl.cxx13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx
index 3c0c92654..011e978e0 100644
--- a/src/Fl.cxx
+++ b/src/Fl.cxx
@@ -861,6 +861,11 @@ Fl_Widget* fl_oldfocus; // kludge for Fl_Group...
\e test if the widget wants the focus (by it returning non-zero from
handle()).
+ Widgets can set the NEEDS_KEYBOARD flag to indicate that a keyboard is
+ essential for the widget to function. Touchscreen devices will be sent a
+ request to show and on-screen keyboard if no hardware keyboard is
+ connected.
+
\see Fl_Widget::take_focus()
*/
void Fl::focus(Fl_Widget *o)
@@ -869,10 +874,12 @@ void Fl::focus(Fl_Widget *o)
// request an on-screen keyboard on touch screen devices if needed
Fl_Widget *prevFocus = Fl::focus();
- if ( prevFocus && (prevFocus->flags()&Fl_Widget::NEEDS_KEYBOARD) )
+ char hideKeyboard = ( prevFocus && (prevFocus->flags()&Fl_Widget::NEEDS_KEYBOARD) );
+ char showKeyboard = (o && (o->flags()&Fl_Widget::NEEDS_KEYBOARD));
+ if (hideKeyboard && !showKeyboard)
Fl::screen_driver()->release_keyboard();
- if (o && (o->flags()&Fl_Widget::NEEDS_KEYBOARD))
- Fl::screen_driver()->request_keyboard( /*o->type()*/ );
+ if (showKeyboard && !hideKeyboard)
+ Fl::screen_driver()->request_keyboard();
if (o && !o->visible_focus()) return;
Fl_Widget *p = focus_;