From 42c0fba64e946181fa7c78f5b8f718d129371a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20H=C3=B6ltt=C3=A4?= Date: Fri, 2 Aug 2019 13:40:39 +0200 Subject: Add currentItem -method Add currentItem -method to the attached CursorNavigation property. The method returns the QQuickItem that currently has the cursor. Change-Id: I3b43f819d915280bfab58639ccfb429fdcf818a4 Reviewed-by: Robert Griebl --- plugin/cursornavigationattached.cpp | 8 ++++++++ plugin/cursornavigationattached.h | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/plugin/cursornavigationattached.cpp b/plugin/cursornavigationattached.cpp index 6e208d5..44bcdb9 100644 --- a/plugin/cursornavigationattached.cpp +++ b/plugin/cursornavigationattached.cpp @@ -242,6 +242,14 @@ void CursorNavigationAttached::escape() } } +QQuickItem *CursorNavigationAttached::currentItem() +{ + if (m_cursorNavigation && m_cursorNavigation->m_currentItem) { + return m_cursorNavigation->m_currentItem->item(); + } + return nullptr; +} + void CursorNavigationAttached::onWindowChanged(QQuickWindow *window) { qDebug() << "window changed, window = " << window; diff --git a/plugin/cursornavigationattached.h b/plugin/cursornavigationattached.h index a005d7c..ac37de3 100644 --- a/plugin/cursornavigationattached.h +++ b/plugin/cursornavigationattached.h @@ -107,7 +107,9 @@ public slots: void moveForward(); void moveBack(); void escape(); - + /* Returns the item that currently has the cursor + */ + QQuickItem *currentItem(); signals: void acceptsCursorChanged(bool acceptsCursor); -- cgit v1.2.3