diff options
author | J-P Nurmi <jpnurmi@digia.com> | 2014-07-18 14:49:00 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@digia.com> | 2014-07-18 16:43:25 +0200 |
commit | 85452fe6f4d30e09107533a488c39f895605aed7 (patch) | |
tree | 9ad75d6228f5e17dceb761705d3101634b5e3c2c /src/controls | |
parent | 1f8cccd791b0fe401692d5a6eaa865606e479cc5 (diff) | |
download | qtquickcontrols-85452fe6f4d30e09107533a488c39f895605aed7.tar.gz |
Add styleData.hasSelection for text selection handles
Text selection handles typically look different based on whether the
editor has selection or not (one handle for moving the cursor vs. two
handles for selecting text). SpinBox and ComboBox do not have suitable
properties for testing whether the control has selection or not, so
styleData.hasSelection is introduced to abstract and expose that
information.
Task-number: QTBUG-38934
Change-Id: I362b5790f5d487e5ba258e42d1b801a5cce76770
Reviewed-by: Liang Qi <liang.qi@digia.com>
Diffstat (limited to 'src/controls')
-rw-r--r-- | src/controls/Private/TextHandle.qml | 1 | ||||
-rw-r--r-- | src/controls/Styles/Base/TextAreaStyle.qml | 2 | ||||
-rw-r--r-- | src/controls/Styles/Base/TextFieldStyle.qml | 2 |
3 files changed, 5 insertions, 0 deletions
diff --git a/src/controls/Private/TextHandle.qml b/src/controls/Private/TextHandle.qml index 3fc6256a..cac80529 100644 --- a/src/controls/Private/TextHandle.qml +++ b/src/controls/Private/TextHandle.qml @@ -61,6 +61,7 @@ Loader { signal activated() readonly property alias pressed: mouse.pressed readonly property alias position: handle.position + readonly property bool hasSelection: editor.selectionStart !== editor.selectionEnd readonly property real lineHeight: position !== -1 ? editor.positionToRectangle(position).height : editor.cursorRectangle.height } diff --git a/src/controls/Styles/Base/TextAreaStyle.qml b/src/controls/Styles/Base/TextAreaStyle.qml index f6bceabc..a147ccc3 100644 --- a/src/controls/Styles/Base/TextAreaStyle.qml +++ b/src/controls/Styles/Base/TextAreaStyle.qml @@ -111,6 +111,7 @@ ScrollViewStyle { \row \li \b {styleData.pressed} : bool \li Whether the handle is pressed. \row \li \b {styleData.position} : int \li The character position of the handle. \row \li \b {styleData.lineHeight} : real \li The height of the line the handle is on. + \row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text. \endtable */ property Component cursorHandle @@ -129,6 +130,7 @@ ScrollViewStyle { \row \li \b {styleData.pressed} : bool \li Whether the handle is pressed. \row \li \b {styleData.position} : int \li The character position of the handle. \row \li \b {styleData.lineHeight} : real \li The height of the line the handle is on. + \row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text. \endtable */ property Component selectionHandle diff --git a/src/controls/Styles/Base/TextFieldStyle.qml b/src/controls/Styles/Base/TextFieldStyle.qml index 13970867..167e09c9 100644 --- a/src/controls/Styles/Base/TextFieldStyle.qml +++ b/src/controls/Styles/Base/TextFieldStyle.qml @@ -169,6 +169,7 @@ Style { \row \li \b {styleData.pressed} : bool \li Whether the handle is pressed. \row \li \b {styleData.position} : int \li The character position of the handle. \row \li \b {styleData.lineHeight} : real \li The height of the line the handle is on. + \row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text. \endtable */ property Component cursorHandle @@ -187,6 +188,7 @@ Style { \row \li \b {styleData.pressed} : bool \li Whether the handle is pressed. \row \li \b {styleData.position} : int \li The character position of the handle. \row \li \b {styleData.lineHeight} : real \li The height of the line the handle is on. + \row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text. \endtable */ property Component selectionHandle |