diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2016-07-05 13:50:59 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2016-07-06 14:21:18 +0000 |
commit | 99c170e3fcd214a15fda00e3419666c1a456b76e (patch) | |
tree | 8ffb2b968c78f356aed3e050f100d7a0b1a9c01b /src/quicktemplates2/qquicktextarea.cpp | |
parent | 39f80448dac5cd46b8dd26b035a17ea5a99c5c40 (diff) |
Add pressed() and released() signals to TextField and TextArea
Users need these to e.g. open context menus when editors are
right-clicked.
[ChangeLog][TextArea][TextField] Added pressed() and released()
signals.
Change-Id: I32b79a8de0120a4f9115fa1c3cb832aff0134a15
Task-number: QTBUG-51009
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquicktextarea.cpp')
-rw-r--r-- | src/quicktemplates2/qquicktextarea.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp index 7bda34f5..96b690fa 100644 --- a/src/quicktemplates2/qquicktextarea.cpp +++ b/src/quicktemplates2/qquicktextarea.cpp @@ -104,6 +104,30 @@ QT_BEGIN_NAMESPACE This signal is emitted when there is a long press (the delay depends on the platform plugin). The \l {MouseEvent}{mouse} parameter provides information about the press, including the x and y position of the press, and which button is pressed. + + \sa pressed, released +*/ + +/*! + \qmlsignal QtQuick.Controls::TextArea::pressed(MouseEvent event) + \since QtQuick.Controls 2.1 + + This signal is emitted when the text area is pressed by the user. + The \l {MouseEvent}{event} parameter provides information about the press, + including the x and y position of the press, and which button is pressed. + + \sa released, pressAndHold +*/ + +/*! + \qmlsignal QtQuick.Controls::TextArea::released(MouseEvent event) + \since QtQuick.Controls 2.1 + + This signal is emitted when the text area is released by the user. + The \l {MouseEvent}{event} parameter provides information about the release, + including the x and y position of the press, and which button is pressed. + + \sa pressed, pressAndHold */ QQuickTextAreaPrivate::QQuickTextAreaPrivate() @@ -283,6 +307,7 @@ QQuickTextArea::QQuickTextArea(QQuickItem *parent) : { Q_D(QQuickTextArea); setActiveFocusOnTab(true); + setAcceptedMouseButtons(Qt::AllButtons); d->setImplicitResizeEnabled(false); d->pressHandler.control = this; QObjectPrivate::connect(this, &QQuickTextEdit::readOnlyChanged, @@ -617,7 +642,12 @@ void QQuickTextArea::mousePressEvent(QMouseEvent *event) QQuickTextEdit::mousePressEvent(d->pressHandler.delayedMousePressEvent); d->pressHandler.clearDelayedMouseEvent(); } + // Calling the base class implementation will result in QQuickTextControl's + // press handler being called, which ignores events that aren't Qt::LeftButton. + const bool wasAccepted = event->isAccepted(); QQuickTextEdit::mousePressEvent(event); + if (wasAccepted) + event->accept(); } } |