summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.cpp21
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitem.h1
2 files changed, 20 insertions, 2 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp
index d19967a..bdd24b6 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp
@@ -1595,10 +1595,10 @@ void QDeclarativeItemPrivate::transform_clear(QDeclarativeListProperty<QGraphics
}
}
-void QDeclarativeItemPrivate::parentProperty(QObject *o, void *rv, QDeclarativeNotifierEndpoint *e)
+void QDeclarativeItemPrivate::parentProperty(QObject *o, void *rv, QDeclarativeNotifierEndpoint *e)
{
QDeclarativeItem *item = static_cast<QDeclarativeItem*>(o);
- if (e)
+ if (e)
e->connect(&item->d_func()->parentNotifier);
*((QDeclarativeItem **)rv) = item->parentItem();
}
@@ -2280,6 +2280,23 @@ QScriptValue QDeclarativeItem::mapToItem(const QScriptValue &item, qreal x, qrea
return sv;
}
+/*!
+ \qmlmethod Item::forceFocus()
+
+ Force the focus on the item.
+ This method sets the focus on the item and makes sure that all the focus scopes higher in the object hierarchy are given focus.
+*/
+void QDeclarativeItem::forceFocus()
+{
+ setFocus(true);
+ QGraphicsItem *parent = parentItem();
+ while (parent) {
+ if (parent->flags() & QGraphicsItem::ItemIsFocusScope)
+ parent->setFocus(Qt::OtherFocusReason);
+ parent = parent->parentItem();
+ }
+}
+
void QDeclarativeItemPrivate::focusChanged(bool flag)
{
Q_Q(QDeclarativeItem);
diff --git a/src/declarative/graphicsitems/qdeclarativeitem.h b/src/declarative/graphicsitems/qdeclarativeitem.h
index 51889f6..da5a36e 100644
--- a/src/declarative/graphicsitems/qdeclarativeitem.h
+++ b/src/declarative/graphicsitems/qdeclarativeitem.h
@@ -157,6 +157,7 @@ public:
Q_INVOKABLE QScriptValue mapFromItem(const QScriptValue &item, qreal x, qreal y) const;
Q_INVOKABLE QScriptValue mapToItem(const QScriptValue &item, qreal x, qreal y) const;
+ Q_INVOKABLE void forceFocus();
QDeclarativeAnchorLine left() const;
QDeclarativeAnchorLine right() const;