From 5f11d2125b9cc37768fb8174870ced5934cdacf2 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 3 Feb 2010 21:42:07 +1000 Subject: Focus focusScope from focusing for focusOnPress Task-number: QTBUG-6739 --- src/declarative/graphicsitems/qmlgraphicstextedit.cpp | 11 ++++++++++- src/declarative/graphicsitems/qmlgraphicstextinput.cpp | 10 ++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp index 6e14d3a..c3495b3 100644 --- a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp +++ b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp @@ -784,8 +784,17 @@ Handles the given mouse \a event. void QmlGraphicsTextEdit::mousePressEvent(QGraphicsSceneMouseEvent *event) { Q_D(QmlGraphicsTextEdit); - if (d->focusOnPress) + if (d->focusOnPress){ + QGraphicsItem *p = parentItem();//###Is there a better way to find my focus scope? + while(p) { + if(p->flags() & QGraphicsItem::ItemIsFocusScope){ + p->setFocus(); + break; + } + p = p->parentItem(); + } setFocus(true); + } d->control->processEvent(event, QPointF(0, 0)); if (!event->isAccepted()) QmlGraphicsPaintedItem::mousePressEvent(event); diff --git a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp index 6068e93..cfb93f6 100644 --- a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp +++ b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp @@ -647,9 +647,15 @@ void QmlGraphicsTextInput::mousePressEvent(QGraphicsSceneMouseEvent *event) { Q_D(QmlGraphicsTextInput); if(d->focusOnPress){ + QGraphicsItem *p = parentItem();//###Is there a better way to find my focus scope? + while(p) { + if(p->flags() & QGraphicsItem::ItemIsFocusScope){ + p->setFocus(); + break; + } + p = p->parentItem(); + } setFocus(true); - setCursorVisible(true); - d->focused = true; } d->control->processEvent(event); } -- cgit v0.12