iOS: Allow virtual keyboard returnKeyType to be set through IM platformData

The result of pressing the key is still a Qt::Key_Return press/release
sequence, which needs to be handled manually.

Change-Id: I72c7b0067bd3ec1bc315ab2c84361800b7be0943
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Reviewed-by: Marius Bugge Monsen <marius@cutehacks.com>
This commit is contained in:
Tor Arne Vestbø 2014-10-28 10:42:56 +01:00
parent c432960718
commit c4cfe9091e
2 changed files with 7 additions and 4 deletions

View File

@ -42,6 +42,7 @@
const char kImePlatformDataInputView[] = "inputView";
const char kImePlatformDataInputAccessoryView[] = "inputAccessoryView";
const char kImePlatformDataReturnKeyType[] = "returnKeyType";
QT_BEGIN_NAMESPACE

View File

@ -173,9 +173,13 @@
m_inSendEventToFocusObject = NO;
m_inputContext = inputContext;
QVariantMap platformData = [self imValue:Qt::ImPlatformData].toMap();
Qt::InputMethodHints hints = Qt::InputMethodHints([self imValue:Qt::ImHints].toUInt());
self.returnKeyType = (hints & Qt::ImhMultiLine) ? UIReturnKeyDefault : UIReturnKeyDone;
self.returnKeyType = platformData.value(kImePlatformDataReturnKeyType).isValid() ?
UIReturnKeyType(platformData.value(kImePlatformDataReturnKeyType).toInt()) :
(hints & Qt::ImhMultiLine) ? UIReturnKeyDefault : UIReturnKeyDone;
self.secureTextEntry = BOOL(hints & Qt::ImhHiddenText);
self.autocorrectionType = (hints & Qt::ImhNoPredictiveText) ?
UITextAutocorrectionTypeNo : UITextAutocorrectionTypeDefault;
@ -202,7 +206,6 @@
else
self.keyboardType = UIKeyboardTypeDefault;
QVariantMap platformData = [self imValue:Qt::ImPlatformData].toMap();
if (UIView *inputView = static_cast<UIView *>(platformData.value(kImePlatformDataInputView).value<void *>()))
self.inputView = [[[WrapperView alloc] initWithView:inputView] autorelease];
if (UIView *accessoryView = static_cast<UIView *>(platformData.value(kImePlatformDataInputAccessoryView).value<void *>()))
@ -625,8 +628,7 @@
[self sendEventToFocusObject:press];
[self sendEventToFocusObject:release];
Qt::InputMethodHints imeHints = static_cast<Qt::InputMethodHints>([self imValue:Qt::ImHints].toUInt());
if (!(imeHints & Qt::ImhMultiLine))
if (self.returnKeyType == UIReturnKeyDone)
[self resignFirstResponder];
return;