qt/interface_window_handler: Make the visualFocus condition generic

Previously this condition was only working for QQuickControl(s). But we might want it
to work with a non Control component, like a TextInput. In that case we declare
a 'visualFocus' property manually and bind it to a parent Control 'visualFocus' property.
This commit is contained in:
Benjamin Arnaud 2022-04-13 16:53:51 +02:00 committed by François Cartegnie
parent 29b742d3a7
commit 7cb89f2ba4
1 changed files with 3 additions and 4 deletions

View File

@ -365,10 +365,9 @@ bool InterfaceWindowHandler::applyKeyEvent(QKeyEvent * event) const
QQuickItem * item = p_intf->p_compositor->activeFocusItem();
// NOTE: When this item is a control and has visual focus we let it handle the key.
if (item && item->inherits("QQuickControl")
&&
QQmlProperty(item, "visualFocus", qmlContext(item)).read().toBool())
// NOTE: When the item has visual focus we let it handle the key. When the item does not
// inherit from QQuickControl we have to declare the 'visualFocus' property ourselves.
if (item && QQmlProperty(item, "visualFocus", qmlContext(item)).read().toBool())
{
return false;
}