summaryrefslogtreecommitdiff
path: root/src/controls
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2014-07-18 07:51:14 +0200
committerJ-P Nurmi <jpnurmi@digia.com>2014-07-18 17:37:49 +0200
commit15d7ab65d1b8772a68258573141874d7f5cd2be5 (patch)
treed10ac54bc5373e7e312b773f2c2b8e0503e783da /src/controls
parent85452fe6f4d30e09107533a488c39f895605aed7 (diff)
downloadqtquickcontrols-15d7ab65d1b8772a68258573141874d7f5cd2be5.tar.gz
SpinBox: add support for selection handles
Task-number: QTBUG-38934 Change-Id: I8f23d20a24977f1787dcd451b48b22326959e3bc Reviewed-by: Liang Qi <liang.qi@digia.com>
Diffstat (limited to 'src/controls')
-rw-r--r--src/controls/SpinBox.qml28
-rw-r--r--src/controls/Styles/Base/SpinBoxStyle.qml38
2 files changed, 55 insertions, 11 deletions
diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml
index d1161784..758be809 100644
--- a/src/controls/SpinBox.qml
+++ b/src/controls/SpinBox.qml
@@ -164,7 +164,7 @@ Control {
This property indicates whether the control is being hovered.
*/
- readonly property bool hovered: mouseArea.containsMouse || cursorArea.containsMouse
+ readonly property bool hovered: mouseArea.containsMouse || input.containsMouse
|| mouseUp.containsMouse || mouseDown.containsMouse
/*!
@@ -181,6 +181,17 @@ Control {
signal editingFinished()
/*!
+ \qmlproperty bool SpinBox::selectByMouse
+ \since QtQuick.Controls 1.3
+
+ This property determines if the user can select the text with the
+ mouse.
+
+ The default value is \c true.
+ */
+ property bool selectByMouse: true
+
+ /*!
\qmlproperty bool SpinBox::inputMethodComposing
\since QtQuick.Controls 1.3
@@ -261,7 +272,7 @@ Control {
}
}
- TextInput {
+ TextInputWithHandles {
id: input
clip: contentWidth > width
anchors.fill: parent
@@ -270,12 +281,15 @@ Control {
anchors.rightMargin: __style ? __style.padding.right: 0
anchors.bottomMargin: __style ? __style.padding.bottom: 0
+ control: spinbox
+ cursorHandle: __style ? __style.cursorHandle : undefined
+ selectionHandle: __style ? __style.selectionHandle : undefined
+
focus: true
activeFocusOnPress: spinbox.activeFocusOnPress
horizontalAlignment: spinbox.horizontalAlignment
verticalAlignment: __panel ? __panel.verticalAlignment : Qt.AlignVCenter
- selectByMouse: activeFocus || activeFocusOnPress
inputMethodHints: Qt.ImhFormattedNumbersOnly
validator: SpinBoxValidator {
@@ -304,14 +318,6 @@ Control {
function selectValue() {
select(prefix.length, text.length - suffix.length)
}
-
- MouseArea {
- id: cursorArea
- anchors.fill: parent
- hoverEnabled: true
- cursorShape: Qt.IBeamCursor
- acceptedButtons: Qt.NoButton
- }
}
// Spinbox increment button
diff --git a/src/controls/Styles/Base/SpinBoxStyle.qml b/src/controls/Styles/Base/SpinBoxStyle.qml
index 6115fc06..e369cb7f 100644
--- a/src/controls/Styles/Base/SpinBoxStyle.qml
+++ b/src/controls/Styles/Base/SpinBoxStyle.qml
@@ -207,4 +207,42 @@ Style {
sourceComponent: decrementControl
}
}
+
+ /*! The cursor handle.
+ \since QtQuick.Controls.Styles 1.3
+
+ The parent of the handle is positioned to the top left corner of
+ the cursor position. The interactive area is determined by the
+ geometry of the handle delegate.
+
+ The following signals and read-only properties are available within the scope
+ of the handle delegate:
+ \table
+ \row \li \b {styleData.activated()} [signal] \li Emitted when the handle is activated ie. the editor is clicked.
+ \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
+
+ /*! The selection handle.
+ \since QtQuick.Controls.Styles 1.3
+
+ The parent of the handle is positioned to the top left corner of
+ the first selected character. The interactive area is determined
+ by the geometry of the handle delegate.
+
+ The following signals and read-only properties are available within the scope
+ of the handle delegate:
+ \table
+ \row \li \b {styleData.activated()} [signal] \li Emitted when the handle is activated ie. the editor is clicked.
+ \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
}