mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-06 05:25:41 -05:00
escape key handling
This commit is contained in:
@@ -334,6 +334,13 @@ DankModal {
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.spacingL
|
||||
spacing: Theme.spacingL
|
||||
focus: true
|
||||
Keys.onPressed: function(event) {
|
||||
if (event.key === Qt.Key_Escape) {
|
||||
hide();
|
||||
event.accepted = true;
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
|
||||
@@ -185,15 +185,28 @@ PanelWindow {
|
||||
|
||||
FocusScope {
|
||||
id: focusScope
|
||||
objectName: "modalFocusScope"
|
||||
|
||||
anchors.fill: parent
|
||||
visible: root.visible // Only active when the modal is visible
|
||||
focus: root.visible
|
||||
Keys.onEscapePressed: (event) => {
|
||||
if (root.closeOnEscapeKey) {
|
||||
root.visible = false;
|
||||
event.accepted = true;
|
||||
}
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
Qt.callLater(function() {
|
||||
focusScope.forceActiveFocus();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Expose the focusScope for external access
|
||||
property alias modalFocusScope: focusScope
|
||||
|
||||
}
|
||||
|
||||
@@ -15,10 +15,14 @@ DankModal {
|
||||
signal closingModal()
|
||||
|
||||
onVisibleChanged: {
|
||||
if (!visible)
|
||||
if (!visible) {
|
||||
if (settingsVisible) {
|
||||
settingsVisible = false;
|
||||
}
|
||||
closingModal();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
visible: settingsVisible
|
||||
width: 750
|
||||
height: 750
|
||||
@@ -27,12 +31,6 @@ DankModal {
|
||||
settingsVisible = false;
|
||||
}
|
||||
|
||||
FocusScope {
|
||||
anchors.fill: parent
|
||||
focus: settingsModal.settingsVisible
|
||||
Keys.onEscapePressed: settingsModal.settingsVisible = false
|
||||
}
|
||||
|
||||
content: Component {
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
|
||||
@@ -194,12 +194,12 @@ DankModal {
|
||||
}
|
||||
|
||||
Connections {
|
||||
function onOpened() {
|
||||
searchField.forceActiveFocus();
|
||||
}
|
||||
|
||||
function onDialogClosed() {
|
||||
searchField.clearFocus();
|
||||
function onSpotlightOpenChanged() {
|
||||
if (spotlightModal.spotlightOpen) {
|
||||
Qt.callLater(function() {
|
||||
searchField.forceActiveFocus();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
target: spotlightModal
|
||||
|
||||
Reference in New Issue
Block a user