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/qdeclarativetextinput.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/qdeclarativetextinput.cpp')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativetextinput.cpp | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index 8aa7e99..2e7715f 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -907,8 +907,12 @@ void QDeclarativeTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event) void QDeclarativeTextInput::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { Q_D(QDeclarativeTextInput); - d->control->moveCursor(d->xToPos(event->pos().x()), true); - event->setAccepted(true); + if (d->selectByMouse) { + d->control->moveCursor(d->xToPos(event->pos().x()), true); + event->setAccepted(true); + } else { + QDeclarativePaintedItem::mouseMoveEvent(event); + } } /*! @@ -939,6 +943,8 @@ bool QDeclarativeTextInput::event(QEvent* ev) case QEvent::GraphicsSceneMouseRelease: break; default: + if (ev->type() == QEvent::GraphicsSceneMouseDoubleClick && !d->selectByMouse) + break; handled = d->control->processEvent(ev); if (ev->type() == QEvent::InputMethod) updateSize(); @@ -1114,6 +1120,32 @@ QString QDeclarativeTextInput::displayText() const } /*! + \qmlproperty string TextInput::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 QDeclarativeTextInput::selectByMouse() const +{ + Q_D(const QDeclarativeTextInput); + return d->selectByMouse; +} + +void QDeclarativeTextInput::setSelectByMouse(bool on) +{ + Q_D(QDeclarativeTextInput); + if (d->selectByMouse != on) { + d->selectByMouse = on; + emit selectByMouseChanged(on); + } +} + + +/*! \qmlmethod void TextInput::moveCursorSelection(int position) Moves the cursor to \a position and updates the selection accordingly. |