summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>2014-02-03 10:20:44 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-06 14:20:01 +0100
commitf9a994e707495578de3279d9330f5fb73bae011f (patch)
tree02ec7d0f4aecc69882e7de2692f51c9a4b31576c /src/plugins/platforms/ios
parent6b212351e239347a9c28cff79d9ee2ef316ac69d (diff)
iOS: return styling hints for text correction pop-ups
By returning the font used at the cursor position, the correction pop-up will be resized to match the point size, and the text marking will get correct height. Change-Id: I362579b793794835323bb9ceb5ddb4655526f392 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
Diffstat (limited to 'src/plugins/platforms/ios')
-rw-r--r--src/plugins/platforms/ios/quiview_textinput.mm18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/plugins/platforms/ios/quiview_textinput.mm b/src/plugins/platforms/ios/quiview_textinput.mm
index 0d9113abc1..ff037b5647 100644
--- a/src/plugins/platforms/ios/quiview_textinput.mm
+++ b/src/plugins/platforms/ios/quiview_textinput.mm
@@ -441,6 +441,24 @@ Q_GLOBAL_STATIC(StaticVariables, staticVariables);
// text instead of just guessing...
}
+- (NSDictionary *)textStylingAtPosition:(UITextPosition *)position inDirection:(UITextStorageDirection)direction
+{
+ Q_UNUSED(position);
+ Q_UNUSED(direction);
+
+ QObject *focusObject = QGuiApplication::focusObject();
+ if (!focusObject)
+ return [NSDictionary dictionary];
+
+ // Assume position is the same as the cursor for now. QInputMethodQueryEvent with Qt::ImFont
+ // needs to be extended to take an extra position argument before this can be fully correct.
+ QInputMethodQueryEvent e(Qt::ImFont);
+ QCoreApplication::sendEvent(focusObject, &e);
+ QFont qfont = qvariant_cast<QFont>(e.value(Qt::ImFont));
+ UIFont *uifont = [UIFont fontWithName:qfont.family().toNSString() size:qfont.pointSize()];
+ return [NSDictionary dictionaryWithObject:uifont forKey:UITextInputTextFontKey];
+}
+
-(NSDictionary *)markedTextStyle
{
return [NSDictionary dictionary];