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>
bb10
Richard Moe Gustavsen 2014-02-03 10:20:44 +01:00 committed by The Qt Project
parent 6b212351e2
commit f9a994e707
1 changed files with 18 additions and 0 deletions

View File

@ -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];