@@ -949,6 +949,8 @@ void QDeclarativeTextInput::setCursorDelegate(QDeclarativeComponent* c)
949
949
// note that the components are owned by something else
950
950
disconnect (d->control , SIGNAL (cursorPositionChanged (int ,int )),
951
951
this , SLOT (moveCursor ()));
952
+ disconnect (d->control , SIGNAL (updateMicroFocus ()),
953
+ this , SLOT (moveCursor ()));
952
954
delete d->cursorItem ;
953
955
}else {
954
956
d->startCreatingCursor ();
@@ -961,7 +963,9 @@ void QDeclarativeTextInputPrivate::startCreatingCursor()
961
963
{
962
964
Q_Q (QDeclarativeTextInput);
963
965
q->connect (control, SIGNAL (cursorPositionChanged (int ,int )),
964
- q, SLOT (moveCursor ()));
966
+ q, SLOT (moveCursor ()), Qt::UniqueConnection);
967
+ q->connect (control, SIGNAL (updateMicroFocus ()),
968
+ q, SLOT (moveCursor ()), Qt::UniqueConnection);
965
969
if (cursorComponent->isReady ()){
966
970
q->createCursor ();
967
971
}else if (cursorComponent->isLoading ()){
@@ -1164,9 +1168,10 @@ void QDeclarativeTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event)
1164
1168
}
1165
1169
if (d->selectByMouse ) {
1166
1170
setKeepMouseGrab (false );
1171
+ d->selectPressed = true ;
1167
1172
d->pressPos = event->pos ();
1168
1173
}
1169
- bool mark = event->modifiers () & Qt::ShiftModifier;
1174
+ bool mark = ( event->modifiers () & Qt::ShiftModifier) && d-> selectByMouse ;
1170
1175
int cursor = d->xToPos (event->pos ().x ());
1171
1176
d->control ->moveCursor (cursor, mark);
1172
1177
event->setAccepted (true );
@@ -1177,7 +1182,7 @@ void QDeclarativeTextInput::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
1177
1182
Q_D (QDeclarativeTextInput);
1178
1183
if (d->sendMouseEventToInputContext (event, QEvent::MouseMove))
1179
1184
return ;
1180
- if (d->selectByMouse ) {
1185
+ if (d->selectPressed ) {
1181
1186
if (qAbs (int (event->pos ().x () - d->pressPos .x ())) > QApplication::startDragDistance ())
1182
1187
setKeepMouseGrab (true );
1183
1188
moveCursorSelection (d->xToPos (event->pos ().x ()), d->mouseSelectionMode );
@@ -1196,8 +1201,10 @@ void QDeclarativeTextInput::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
1196
1201
Q_D (QDeclarativeTextInput);
1197
1202
if (d->sendMouseEventToInputContext (event, QEvent::MouseButtonRelease))
1198
1203
return ;
1199
- if (d->selectByMouse )
1204
+ if (d->selectPressed ) {
1205
+ d->selectPressed = false ;
1200
1206
setKeepMouseGrab (false );
1207
+ }
1201
1208
if (!d->showInputPanelOnFocus ) { // input panel on click
1202
1209
if (d->focusOnPress && !isReadOnly () && boundingRect ().contains (event->pos ())) {
1203
1210
if (QGraphicsView * view = qobject_cast<QGraphicsView*>(qApp->focusWidget ())) {
@@ -1253,8 +1260,10 @@ bool QDeclarativeTextInputPrivate::sendMouseEventToInputContext(
1253
1260
1254
1261
bool QDeclarativeTextInput::sceneEvent (QEvent *event)
1255
1262
{
1263
+ Q_D (QDeclarativeTextInput);
1256
1264
bool rv = QDeclarativeItem::sceneEvent (event);
1257
1265
if (event->type () == QEvent::UngrabMouse) {
1266
+ d->selectPressed = false ;
1258
1267
setKeepMouseGrab (false );
1259
1268
}
1260
1269
return rv;
0 commit comments