summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>2014-07-23 11:33:48 +0200
committerRichard Moe Gustavsen <richard.gustavsen@digia.com>2014-09-23 17:46:07 +0200
commit229c4b0a71c888c37fad054c2fabaecfa3ba73fc (patch)
treedce058ff2feab69504056150848783ad785afbbc
parent26db5c724540449ef1e19178427081bff084e4ad (diff)
downloadqtquickcontrols-229c4b0a71c888c37fad054c2fabaecfa3ba73fc.tar.gz
Add EditMenu to input controls
Add EditMenu to TextArea, TextField, ComboBox and SpinBox. Change-Id: Ic2fed55c467dde65334006d252f4052430f3f40c Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
-rw-r--r--src/controls/ComboBox.qml12
-rw-r--r--src/controls/Private/TextInputWithHandles.qml10
-rw-r--r--src/controls/SpinBox.qml10
-rw-r--r--src/controls/TextArea.qml20
-rw-r--r--src/controls/TextField.qml10
5 files changed, 62 insertions, 0 deletions
diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml
index fc8cf321..1dba6b7e 100644
--- a/src/controls/ComboBox.qml
+++ b/src/controls/ComboBox.qml
@@ -222,6 +222,18 @@ Control {
property alias validator: input.validator
/*!
+ \qmlproperty Menu ComboBox::menu
+ \since QtQuick.Controls 1.3
+
+ This property contains the edit menu for working
+ with text selection. Set it to \c null if no menu
+ is wanted.
+
+ \note The menu is only in use when \l editable is \c true
+ */
+ property Menu menu: input.editMenu.defaultMenu
+
+ /*!
\qmlproperty bool ComboBox::acceptableInput
\since QtQuick.Controls 1.1
diff --git a/src/controls/Private/TextInputWithHandles.qml b/src/controls/Private/TextInputWithHandles.qml
index 59ba971e..e5d72f96 100644
--- a/src/controls/Private/TextInputWithHandles.qml
+++ b/src/controls/Private/TextInputWithHandles.qml
@@ -51,6 +51,7 @@ TextInput {
property bool hasSelection: selectionStart !== selectionEnd
readonly property int selectionPosition: selectionStart !== cursorPosition ? selectionStart : selectionEnd
readonly property alias containsMouse: mouseArea.containsMouse
+ property alias editMenu: editMenu
selectByMouse: control.selectByMouse && (!cursorHandle.delegate || !selectionHandle.delegate)
@@ -115,6 +116,15 @@ TextInput {
}
}
+ EditMenu {
+ id: editMenu
+ input: parent
+ control: parent.control
+ cursorHandle: cursorHandle
+ selectionHandle: selectionHandle
+ anchors.fill: parent
+ }
+
TextHandle {
id: selectionHandle
diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml
index 758be809..f4b89ae6 100644
--- a/src/controls/SpinBox.qml
+++ b/src/controls/SpinBox.qml
@@ -203,6 +203,16 @@ Control {
*/
readonly property bool inputMethodComposing: !!input.inputMethodComposing
+ /*!
+ \qmlproperty Menu SpinBox::menu
+ \since QtQuick.Controls 1.3
+
+ This property contains the edit menu for working
+ with text selection. Set it to \c null if no menu
+ is wanted.
+ */
+ property Menu menu: input.editMenu.defaultMenu
+
style: Qt.createComponent(Settings.style + "/SpinBoxStyle.qml", spinbox)
/*! \internal */
diff --git a/src/controls/TextArea.qml b/src/controls/TextArea.qml
index 1f06569c..d8181ab9 100644
--- a/src/controls/TextArea.qml
+++ b/src/controls/TextArea.qml
@@ -436,6 +436,16 @@ ScrollView {
readonly property alias hoveredLink: edit.hoveredLink
/*!
+ \qmlproperty Menu TextArea::menu
+ \since QtQuick.Controls 1.3
+
+ This property contains the edit menu for working
+ with text selection. Set it to \c null if no menu
+ is wanted.
+ */
+ property Menu menu: editMenu.defaultMenu
+
+ /*!
\qmlmethod TextArea::append(string)
Appends \a string as a new line to the end of the text area.
@@ -849,6 +859,16 @@ ScrollView {
}
}
+ EditMenu {
+ id: editMenu
+ control: area
+ input: edit
+ cursorHandle: cursorHandle
+ selectionHandle: selectionHandle
+ flickable: flickable
+ anchors.fill: parent
+ }
+
TextHandle {
id: selectionHandle
diff --git a/src/controls/TextField.qml b/src/controls/TextField.qml
index 797c3fc2..7417beb8 100644
--- a/src/controls/TextField.qml
+++ b/src/controls/TextField.qml
@@ -434,6 +434,16 @@ Control {
property alias validator: textInput.validator
/*!
+ \qmlproperty Menu TextField::menu
+ \since QtQuick.Controls 1.3
+
+ This property contains the edit menu for working
+ with text selection. Set it to \c null if no menu
+ is wanted.
+ */
+ property Menu menu: textInput.editMenu.defaultMenu
+
+ /*!
\qmlsignal TextField::accepted()
This signal is emitted when the Return or Enter key is pressed.