summaryrefslogtreecommitdiffstats
path: root/src/declarative/fx/qfxtextedit.cpp
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-05-21 01:45:41 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-05-21 01:45:41 (GMT)
commit942ea5202d4a329376c27015b07406c2018437ff (patch)
treeb8bd7f482458b2f65b5d8df63a0a2cb2825c1955 /src/declarative/fx/qfxtextedit.cpp
parentf6b9e75f3f7fd7bdef3855dd07ffdc9fa10b2dae (diff)
downloadQt-942ea5202d4a329376c27015b07406c2018437ff.zip
Qt-942ea5202d4a329376c27015b07406c2018437ff.tar.gz
Qt-942ea5202d4a329376c27015b07406c2018437ff.tar.bz2
Add a preserveSelection property to TextEdit.
This property will allow us to get line edit-like behavior, where the selection is removed when the item loses focus.
Diffstat (limited to 'src/declarative/fx/qfxtextedit.cpp')
-rw-r--r--src/declarative/fx/qfxtextedit.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp
index b2da051..f59e0ae 100644
--- a/src/declarative/fx/qfxtextedit.cpp
+++ b/src/declarative/fx/qfxtextedit.cpp
@@ -427,6 +427,8 @@ void QFxTextEdit::setCursorVisible(bool on)
return;
d->cursorVisible = on;
QFocusEvent focusEvent(on ? QEvent::FocusIn : QEvent::FocusOut);
+ if (!on && !d->preserveSelection)
+ d->control->setCursorIsFocusIndicator(true);
d->control->processEvent(&focusEvent, QPointF(0, 0));
}
@@ -450,6 +452,26 @@ void QFxTextEdit::setFocusOnPress(bool on)
d->focusOnPress = on;
}
+/*!
+ \qmlproperty bool TextEdit::preserveSelection
+
+ Whether the TextEdit should keep the selection visible when it loses focus to another
+ item in the scene. By default this is set to true;
+*/
+bool QFxTextEdit::preserveSelection() const
+{
+ Q_D(const QFxTextEdit);
+ return d->preserveSelection;
+}
+
+void QFxTextEdit::setPreserveSelection(bool on)
+{
+ Q_D(QFxTextEdit);
+ if (d->preserveSelection == on)
+ return;
+ d->preserveSelection = on;
+}
+
void QFxTextEdit::geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry)
{