diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-07-21 02:23:15 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-07-21 02:33:18 (GMT) |
commit | 21806ff0921641b4e4d9d39721ab4ebeae74dddc (patch) | |
tree | 6f854d6279385c120986f0288eb997373058106a /src/declarative/graphicsitems/qdeclarativetextedit.cpp | |
parent | 4f6e480acce94d8ae920c3eda4879fc4f9cb2598 (diff) | |
download | Qt-21806ff0921641b4e4d9d39721ab4ebeae74dddc.zip Qt-21806ff0921641b4e4d9d39721ab4ebeae74dddc.tar.gz Qt-21806ff0921641b4e4d9d39721ab4ebeae74dddc.tar.bz2 |
QML focus API updates.
The wantsFocus property has been renamed to activeFocus, to better
reflect its value. Reading and writing the focus property is also now
consistent -- this property represents focus within a scope. Other small
changes were made to keep things consistent with the new naming.
Reviewed-by: Aaron Kennedy
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativetextedit.cpp')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativetextedit.cpp | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 0cbada4..f7b2ebf 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -624,7 +624,7 @@ void QDeclarativeTextEdit::moveCursorSelection(int pos) \qmlproperty bool TextEdit::cursorVisible If true the text edit shows a cursor. - This property is set and unset when the text edit gets focus, but it can also + This property is set and unset when the text edit gets active focus, but it can also be set directly (useful, for example, if a KeyProxy might forward keys to it). */ bool QDeclarativeTextEdit::isCursorVisible() const @@ -783,9 +783,9 @@ QString QDeclarativeTextEdit::selectedText() const } /*! - \qmlproperty bool TextEdit::focusOnPress + \qmlproperty bool TextEdit::activeFocusOnPress - Whether the TextEdit should gain focus on a mouse press. By default this is + Whether the TextEdit should gain active focus on a mouse press. By default this is set to true. */ bool QDeclarativeTextEdit::focusOnPress() const @@ -800,13 +800,13 @@ void QDeclarativeTextEdit::setFocusOnPress(bool on) if (d->focusOnPress == on) return; d->focusOnPress = on; - emit focusOnPressChanged(d->focusOnPress); + emit activeFocusOnPressChanged(d->focusOnPress); } /*! \qmlproperty bool TextEdit::persistentSelection - Whether the TextEdit should keep the selection visible when it loses focus to another + Whether the TextEdit should keep the selection visible when it loses active focus to another item in the scene. By default this is set to true; */ bool QDeclarativeTextEdit::persistentSelection() const @@ -1106,15 +1106,15 @@ void QDeclarativeTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event) { Q_D(QDeclarativeTextEdit); if (d->focusOnPress){ - bool hadFocus = hasFocus(); - forceFocus(); + bool hadActiveFocus = hasActiveFocus(); + forceActiveFocus(); if (d->showInputPanelOnFocus) { - if (hasFocus() && hadFocus && !isReadOnly()) { + if (hasActiveFocus() && hadActiveFocus && !isReadOnly()) { // re-open input panel on press if already focused openSoftwareInputPanel(); } } else { // show input panel on click - if (hasFocus() && !hadFocus) { + if (hasActiveFocus() && !hadActiveFocus) { d->clickCausedFocus = true; } } @@ -1427,10 +1427,10 @@ void QDeclarativeTextEditPrivate::updateDefaultTextOption() By default the opening of input panels follows the platform style. On Symbian^1 and Symbian^3 -based devices the panels are opened by clicking TextEdit. On other platforms - the panels are automatically opened when TextEdit element gains focus. Input panels are - always closed if no editor owns focus. + the panels are automatically opened when TextEdit element gains active focus. Input panels are + always closed if no editor has active focus. - You can disable the automatic behavior by setting the property \c focusOnPress to false + You can disable the automatic behavior by setting the property \c activeFocusOnPress to false and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement the behavior you want. @@ -1441,12 +1441,12 @@ void QDeclarativeTextEditPrivate::updateDefaultTextOption() TextEdit { id: textEdit text: "Hello world!" - focusOnPress: false + activeFocusOnPress: false MouseArea { anchors.fill: parent onClicked: { - if (!textEdit.focus) { - textEdit.focus = true; + if (!textEdit.activeFocus) { + textEdit.forceActiveFocus(); textEdit.openSoftwareInputPanel(); } else { textEdit.focus = false; @@ -1478,10 +1478,10 @@ void QDeclarativeTextEdit::openSoftwareInputPanel() By default the opening of input panels follows the platform style. On Symbian^1 and Symbian^3 -based devices the panels are opened by clicking TextEdit. On other platforms - the panels are automatically opened when TextEdit element gains focus. Input panels are - always closed if no editor owns focus. + the panels are automatically opened when TextEdit element gains active focus. Input panels are + always closed if no editor has active focus. - You can disable the automatic behavior by setting the property \c focusOnPress to false + You can disable the automatic behavior by setting the property \c activeFocusOnPress to false and use functions openSoftwareInputPanel() and closeSoftwareInputPanel() to implement the behavior you want. @@ -1492,12 +1492,12 @@ void QDeclarativeTextEdit::openSoftwareInputPanel() TextEdit { id: textEdit text: "Hello world!" - focusOnPress: false + activeFocusOnPress: false MouseArea { anchors.fill: parent onClicked: { - if (!textEdit.focus) { - textEdit.focus = true; + if (!textEdit.activeFocus) { + textEdit.forceActiveFocus(); textEdit.openSoftwareInputPanel(); } else { textEdit.focus = false; |