diff options
author | Alexis Menard <alexis.menard@nokia.com> | 2010-02-08 07:45:44 (GMT) |
---|---|---|
committer | Alexis Menard <alexis.menard@nokia.com> | 2010-02-08 07:45:44 (GMT) |
commit | 78fce53374d4aad0e51d7086268579913c19a1ac (patch) | |
tree | cce07d5037fc4f405ce8ca255d31faecfbe9fddd /src | |
parent | e5c58224e1ebbfc6cdac3e2f611d71c6654b3642 (diff) | |
download | Qt-78fce53374d4aad0e51d7086268579913c19a1ac.zip Qt-78fce53374d4aad0e51d7086268579913c19a1ac.tar.gz Qt-78fce53374d4aad0e51d7086268579913c19a1ac.tar.bz2 |
The virtual keyboard is now working for TextEdit and TextInput components.
In order to show the virtual keyboard we need to send
RequestSoftwareInputPanel. I also fixed TextInput regarding the
inputQuery implementation.
Task-number:QTBUG-7602
Reviewed-by:akennedy
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicstextedit.cpp | 4 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicstextinput.cpp | 44 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicstextinput_p.h | 3 |
3 files changed, 51 insertions, 0 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp index c3495b3..fc80258 100644 --- a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp +++ b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp @@ -807,6 +807,10 @@ Handles the given mouse \a event. void QmlGraphicsTextEdit::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { Q_D(QmlGraphicsTextEdit); + QWidget *widget = event->widget(); + if (widget && (d->control->textInteractionFlags() & Qt::TextEditable) && boundingRect().contains(event->pos())) + qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), d->focusOnPress); + d->control->processEvent(event, QPointF(0, 0)); if (!event->isAccepted()) QmlGraphicsPaintedItem::mousePressEvent(event); diff --git a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp index cfb93f6..427f9ff 100644 --- a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp +++ b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp @@ -660,6 +660,19 @@ void QmlGraphicsTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event) d->control->processEvent(event); } +/*! +\overload +Handles the given mouse \a event. +*/ +void QmlGraphicsTextInput::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +{ + Q_D(QmlGraphicsTextInput); + QWidget *widget = event->widget(); + if (widget && !d->control->isReadOnly() && boundingRect().contains(event->pos())) + qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), d->focusOnPress); + d->control->processEvent(event); +} + bool QmlGraphicsTextInput::event(QEvent* ev) { Q_D(QmlGraphicsTextInput); @@ -669,6 +682,7 @@ bool QmlGraphicsTextInput::event(QEvent* ev) case QEvent::KeyPress: case QEvent::KeyRelease://###Should the control be doing anything with release? case QEvent::GraphicsSceneMousePress: + case QEvent::GraphicsSceneMouseRelease: break; default: handled = d->control->processEvent(ev); @@ -721,6 +735,36 @@ void QmlGraphicsTextInput::drawContents(QPainter *p, const QRect &r) p->restore(); } +/*! +\overload +Returns the value of the given \a property. +*/ +QVariant QmlGraphicsTextInput::inputMethodQuery(Qt::InputMethodQuery property) const +{ + Q_D(const QmlGraphicsTextInput); + switch(property) { + case Qt::ImFont: + return font(); + case Qt::ImCursorPosition: + return QVariant(d->control->cursor()); + case Qt::ImSurroundingText: + return QVariant(text()); + case Qt::ImCurrentSelection: + return QVariant(selectedText()); + case Qt::ImMaximumTextLength: + return QVariant(maxLength()); + case Qt::ImAnchorPosition: + if (d->control->selectionStart() == d->control->selectionEnd()) + return QVariant(d->control->cursor()); + else if (d->control->selectionStart() == d->control->cursor()) + return QVariant(d->control->selectionEnd()); + else + return QVariant(d->control->selectionStart()); + default: + return QVariant(); + } +} + void QmlGraphicsTextInput::selectAll() { Q_D(QmlGraphicsTextInput); diff --git a/src/declarative/graphicsitems/qmlgraphicstextinput_p.h b/src/declarative/graphicsitems/qmlgraphicstextinput_p.h index 24e473d..56f16a5 100644 --- a/src/declarative/graphicsitems/qmlgraphicstextinput_p.h +++ b/src/declarative/graphicsitems/qmlgraphicstextinput_p.h @@ -164,6 +164,8 @@ public: bool hasAcceptableInput() const; void drawContents(QPainter *p,const QRect &r); + QVariant inputMethodQuery(Qt::InputMethodQuery property) const; + Q_SIGNALS: void textChanged(); void cursorPositionChanged(); @@ -191,6 +193,7 @@ protected: const QRectF &oldGeometry); void mousePressEvent(QGraphicsSceneMouseEvent *event); + void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void keyPressEvent(QKeyEvent* ev); bool event(QEvent *e); |