summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Fl.cxx13
-rw-r--r--src/drivers/Android/Fl_Android_Screen_Keyboard.cxx6
2 files changed, 14 insertions, 5 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_;
diff --git a/src/drivers/Android/Fl_Android_Screen_Keyboard.cxx b/src/drivers/Android/Fl_Android_Screen_Keyboard.cxx
index 91a78f42b..c708040ec 100644
--- a/src/drivers/Android/Fl_Android_Screen_Keyboard.cxx
+++ b/src/drivers/Android/Fl_Android_Screen_Keyboard.cxx
@@ -363,8 +363,10 @@ int64_t AKeyEvent_getEventTime (const AInputEvent *key_event)
return 0;
}
-
-void Fl_Android_Screen_Driver::request_keyboard()
+// TODO: different inputs may be able to request different keyboards
+// TODO: knowing the position of the widget, we may be able to avoid
+// obstructing it with the on-screen keyboard
+void Fl_Android_Screen_Driver::request_keyboard( /*o->rect(), o->type()*/ )
{
if (pKeyboardCount==0) {
/*