diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2019-12-11 16:38:14 +0100 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2019-12-12 16:04:48 +0100 |
commit | 0425562e14e41b62dc7631c7c02768b8294454d0 (patch) | |
tree | 733b22fb261624f99c9b8ab48888512b4793619d /src/quicktemplates2/qquickcombobox.cpp | |
parent | 9a9ae6be7d278cdcaf6ac99ea22b3d6cf1093313 (diff) |
ComboBox: add selectTextByMouse property
Allows configuring the selectByMouse property of the underlying
TextField for editable combo boxes.
Named selectTextByMouse instead of selectByMouse to avoid confusion
with selection of the items themselves.
[ChangeLog][Controls][ComboBox] Added selectTextByMouse property.
Change-Id: I852e4cd44ebe6b2a1ed2535513ea2fc35cbe0a32
Fixes: QTBUG-71406
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickcombobox.cpp')
-rw-r--r-- | src/quicktemplates2/qquickcombobox.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index 199e3408..79ee6663 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -293,6 +293,7 @@ public: bool editable = false; bool accepting = false; bool allowComplete = false; + bool selectTextByMouse = false; Qt::InputMethodHints inputMethodHints = Qt::ImhNone; QString editText; QValidator *validator = nullptr; @@ -1568,6 +1569,30 @@ int QQuickComboBox::indexOfValue(const QVariant &value) const } /*! + \since QtQuick.Controls 2.15 (Qt 5.15) + \qmlproperty bool QtQuick.Controls::ComboBox::selectTextByMouse + + This property holds whether the text field for an editable ComboBox + can be selected with the mouse. + + The default value is \c false. +*/ +bool QQuickComboBox::selectTextByMouse() const +{ + Q_D(const QQuickComboBox); + return d->extra.isAllocated() ? d->extra->selectTextByMouse : false; +} + +void QQuickComboBox::setSelectTextByMouse(bool canSelect) +{ + Q_D(QQuickComboBox); + if (canSelect == selectTextByMouse()) + return; + + d->extra.value().selectTextByMouse = canSelect; + emit selectTextByMouseChanged(); +} +/*! \qmlmethod string QtQuick.Controls::ComboBox::textAt(int index) Returns the text for the specified \a index, or an empty string |