diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-05-19 06:44:09 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-05-19 06:44:09 (GMT) |
commit | fd02170f2fd241b53a20668c6354249bdeab3e1a (patch) | |
tree | 02c7f568321bfa28190a0f27f95cea55d267db93 /src/declarative/graphicsitems/qdeclarativetextedit.cpp | |
parent | 36c51fe5229580ddaef7b7feb23822ecb775bffc (diff) | |
download | Qt-fd02170f2fd241b53a20668c6354249bdeab3e1a.zip Qt-fd02170f2fd241b53a20668c6354249bdeab3e1a.tar.gz Qt-fd02170f2fd241b53a20668c6354249bdeab3e1a.tar.bz2 |
Disable mouse-based selection in TextInput/TextEdit
Can still be turned back on, if people only want to target platforms
where the behaviour is acceptable.
Task-number: QTBUG-10684
Reviewed-by: Michael Brasser
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativetextedit.cpp')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativetextedit.cpp | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 45b79a7..40d37a2 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -773,6 +773,33 @@ void QDeclarativeTextEdit::componentComplete() } /*! + \qmlproperty string TextEdit::selectByMouse + + Defaults to false. + + If true, the user can use the mouse to select text in some + platform-specific way. Note that for some platforms this may + not be an appropriate interaction (eg. may conflict with how + the text needs to behave inside a Flickable. +*/ +bool QDeclarativeTextEdit::selectByMouse() const +{ + Q_D(const QDeclarativeTextEdit); + return d->selectByMouse; +} + +void QDeclarativeTextEdit::setSelectByMouse(bool on) +{ + Q_D(QDeclarativeTextEdit); + if (d->selectByMouse != on) { + d->selectByMouse = on; + emit selectByMouseChanged(on); + } +} + + + +/*! \qmlproperty bool TextEdit::readOnly Whether the user an interact with the TextEdit item. If this @@ -914,7 +941,8 @@ void QDeclarativeTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event) } if (!hadFocus && hasFocus()) d->clickCausedFocus = true; - d->control->processEvent(event, QPointF(0, 0)); + if (event->type() != QEvent::GraphicsSceneMouseDoubleClick || d->selectByMouse) + d->control->processEvent(event, QPointF(0, 0)); if (!event->isAccepted()) QDeclarativePaintedItem::mousePressEvent(event); } @@ -943,9 +971,13 @@ Handles the given mouse \a event. void QDeclarativeTextEdit::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) { Q_D(QDeclarativeTextEdit); - d->control->processEvent(event, QPointF(0, 0)); - if (!event->isAccepted()) + if (d->selectByMouse) { + d->control->processEvent(event, QPointF(0, 0)); + if (!event->isAccepted()) + QDeclarativePaintedItem::mouseDoubleClickEvent(event); + } else { QDeclarativePaintedItem::mouseDoubleClickEvent(event); + } } /*! @@ -955,10 +987,14 @@ Handles the given mouse \a event. void QDeclarativeTextEdit::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { Q_D(QDeclarativeTextEdit); - d->control->processEvent(event, QPointF(0, 0)); - if (!event->isAccepted()) + if (d->selectByMouse) { + d->control->processEvent(event, QPointF(0, 0)); + if (!event->isAccepted()) + QDeclarativePaintedItem::mouseMoveEvent(event); + event->setAccepted(true); + } else { QDeclarativePaintedItem::mouseMoveEvent(event); - event->setAccepted(true); + } } /*! |