1
mirror of https://code.videolan.org/videolan/vlc synced 2024-07-21 07:24:15 +02:00

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

View File

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