mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-12 21:39:38 +02:00
Merge pull request #5678 from SeijiEmery/addressbar
Address bar now closes when you click outside of it
This commit is contained in:
commit
710f7c002e
2 changed files with 22 additions and 0 deletions
|
@ -151,6 +151,17 @@ DialogContainer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Connect to parent's signals (Root.qml)
|
||||||
|
onParentChanged: {
|
||||||
|
// Hide the address bar when the user clicks outside it
|
||||||
|
// Note: if the user clicks on another dialog this won't get called.
|
||||||
|
|
||||||
|
if (parent && parent.unhandledClick) {
|
||||||
|
parent.unhandledClick.connect(function () {
|
||||||
|
root.enabled = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
onVisibleChanged: {
|
onVisibleChanged: {
|
||||||
if (!visible) {
|
if (!visible) {
|
||||||
addressLine.text = ""
|
addressLine.text = ""
|
||||||
|
@ -165,6 +176,7 @@ DialogContainer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Keys.onPressed: {
|
Keys.onPressed: {
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
case Qt.Key_Escape:
|
case Qt.Key_Escape:
|
||||||
|
|
|
@ -6,6 +6,16 @@ import QtQuick 2.3
|
||||||
Root {
|
Root {
|
||||||
id: root
|
id: root
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
signal unhandledClick();
|
||||||
|
|
||||||
|
// Detects a mouseclick that is not handled by any child components.
|
||||||
|
// Used by AddressBarDialog.qml to close when user clicks outside of it.
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
unhandledClick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onParentChanged: {
|
onParentChanged: {
|
||||||
forceActiveFocus();
|
forceActiveFocus();
|
||||||
|
|
Loading…
Reference in a new issue