diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-05-12 01:46:36 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-05-12 01:46:36 (GMT) |
commit | 4ea4c6d103034cbe063004ba7a533cf4e56b1922 (patch) | |
tree | 1cf975970d4fef159ba0ff62c8845adef264559b /src/declarative/fx/qfxtextedit.cpp | |
parent | 1d48c20c9471a8079a15247522becd2908e3c114 (diff) | |
download | Qt-4ea4c6d103034cbe063004ba7a533cf4e56b1922.zip Qt-4ea4c6d103034cbe063004ba7a533cf4e56b1922.tar.gz Qt-4ea4c6d103034cbe063004ba7a533cf4e56b1922.tar.bz2 |
TextEdit fixes and improvements.
Get cursor blinking working again. Add focusOnPress to make it easy to
gain focus when the mouse is pressed.
Diffstat (limited to 'src/declarative/fx/qfxtextedit.cpp')
-rw-r--r-- | src/declarative/fx/qfxtextedit.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp index 74c9b5b..35b1173 100644 --- a/src/declarative/fx/qfxtextedit.cpp +++ b/src/declarative/fx/qfxtextedit.cpp @@ -430,6 +430,26 @@ void QFxTextEdit::setCursorVisible(bool on) d->control->processEvent(&focusEvent, QPointF(0, 0)); } +/*! + \qmlproperty bool TextEdit::focusOnPress + + Whether the TextEdit should gain focus on a mouse press. By default this is + set to false; +*/ +bool QFxTextEdit::focusOnPress() const +{ + Q_D(const QFxTextEdit); + return d->focusOnPress; +} + +void QFxTextEdit::setFocusOnPress(bool on) +{ + Q_D(QFxTextEdit); + if (d->focusOnPress == on) + return; + d->focusOnPress = on; +} + void QFxTextEdit::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { @@ -643,6 +663,7 @@ void QFxTextEdit::keyReleaseEvent(QKeyEvent *event) void QFxTextEdit::focusChanged(bool hasFocus) { Q_D(QFxTextEdit); + setCursorVisible(hasFocus); } /*! @@ -684,6 +705,8 @@ Handles the given mouse \a event. void QFxTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event) { Q_D(QFxTextEdit); + if (d->focusOnPress) + setFocus(true); QMouseEvent *me = sceneMouseEventToMouseEvent(event); d->control->processEvent(me, QPointF(0, 0)); event->setAccepted(me->isAccepted()); |