path: root/src/plugins/platforms/ios/qiosinputcontext.h
diff options
authorTor Arne Vestbø <>2014-12-01 13:54:36 +0100
committerTor Arne Vestbø <>2014-12-02 10:57:01 +0100
commitdf75cb4c093dfc0a6a3e926bbfd6e6943c9cdd1b (patch)
treea50e8ef02625f73537533e659a6a5db4c478c41e /src/plugins/platforms/ios/qiosinputcontext.h
parent44e9e7fe199f197fe1e639e5fbcf858f4775d31b (diff)
iOS: Properly support QInputMethod's visible and animating properties
We now emit and change the 'visible' and 'animating' properties of the QInputMethod according to the documentation, which means the 'visible' property will change immediately when the keyboard is about to become visible, or about to hide, and the 'animating' property will determine if the visibility-change is just starting out, or has ended. The keyboard rect will at all times reflect the currently visible area of the virtual keyboard on screen (in focus-window-coordinates), not future state after the animating completes. Getting the future state is a missing piece of the QInputMethod API, and could be solved in the future by adding arguments to the animatingChanged signal that allow platform plugins to pass on the before- and after states. The logic for determining the keyboard state has been moved into a central function, updateKeyboardState(), which allows us to change and emit property changes atomically. There is still some parts left of the old approach, but these are left in to make further changes to the code easier to diff and understand in isolation. Change-Id: Ica52718eba503165ba101f1f82c4a425e3621002 Reviewed-by: Richard Moe Gustavsen <>
Diffstat (limited to 'src/plugins/platforms/ios/qiosinputcontext.h')
1 files changed, 22 insertions, 4 deletions
diff --git a/src/plugins/platforms/ios/qiosinputcontext.h b/src/plugins/platforms/ios/qiosinputcontext.h
index eb6b04a2ac..863e503c3b 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.h
+++ b/src/plugins/platforms/ios/qiosinputcontext.h
@@ -50,6 +50,21 @@ QT_BEGIN_NAMESPACE
@class QIOSTextInputResponder;
@protocol KeyboardState;
+struct KeyboardState
+ KeyboardState() :
+ keyboardVisible(false), keyboardAnimating(false),
+ animationDuration(0), animationCurve(UIViewAnimationCurve(-1))
+ {}
+ bool keyboardVisible;
+ bool keyboardAnimating;
+ QRectF keyboardRect;
+ CGRect keyboardEndRect;
+ NSTimeInterval animationDuration;
+ UIViewAnimationCurve animationCurve;
struct ImeState
ImeState() : currentState(0), focusObject(0) {}
@@ -70,6 +85,7 @@ public:
void hideInputPanel() Q_DECL_OVERRIDE;
bool isInputPanelVisible() const Q_DECL_OVERRIDE;
+ bool isAnimating() const Q_DECL_OVERRIDE;
QRectF keyboardRect() const Q_DECL_OVERRIDE;
void update(Qt::InputMethodQueries) Q_DECL_OVERRIDE;
@@ -85,7 +101,11 @@ public:
void scrollToCursor();
void scroll(int y);
+ void updateKeyboardState(NSNotification *notification = 0);
const ImeState &imeState() { return m_imeState; };
+ const KeyboardState &keyboardState() { return m_keyboardState; };
bool inputMethodAccepted() const;
static QIOSInputContext *instance();
@@ -93,11 +113,9 @@ public:
UIView* scrollableRootView();
- union {
- QIOSKeyboardListener *m_keyboardHideGesture;
- id <KeyboardState> m_keyboardState;
- };
+ QIOSKeyboardListener *m_keyboardHideGesture;
QIOSTextInputResponder *m_textResponder;
+ KeyboardState m_keyboardState;
ImeState m_imeState;