Skip to content
  • Mitch Curtis's avatar
    ApplicationWindow: top level items must get focus when they ask for it. · 85f57be3
    Mitch Curtis authored
    
    
    Currently, the following Item will not receive any key events:
    
        import QtQuick 2.2
        import QtQuick.Controls 1.2
    
        ApplicationWindow {
            visible: true
            width: 200
            height: 200
    
            Item {
                focus: true
                anchors.fill: parent
    
                Keys.onLeftPressed: textItem.text = "Left"
                Keys.onRightPressed: textItem.text = "Right"
                Keys.onPressed: {
                    if (event.key === Qt.Key_Home) {
                        textItem.text = "Home";
                    } else if (event.key === Qt.Key_End) {
                        textItem.text = "End";
                    }
                }
    
                Text {
                    id: textItem
                    anchors.centerIn: parent
                }
            }
        }
    
    Using Window instead of ApplicationWindow does, however.
    ApplicationWindow can behave the same if we ensure that the panel has
    focus set to true. When the panel has focus, the contentItem can
    receive focus.
    
    [ChangeLog][ApplicationWindow] Top level items now receive focus when
    their focus property is set to true, in the same way that top level
    items of Window do.
    
    Change-Id: I16ef1632fc6df1989015e62e8683b6cd7c5be8a6
    Reviewed-by: default avatarJ-P Nurmi <jpnurmi@digia.com>
    Reviewed-by: default avatarLiang Qi <liang.qi@digia.com>
    85f57be3