1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-08 06:25:37 -05:00

fix auto focusing text fields

This commit is contained in:
bbedward
2025-07-22 23:51:18 -04:00
parent 9c8c25711c
commit e94d2af9ae
6 changed files with 41 additions and 36 deletions

View File

@@ -149,9 +149,6 @@ PanelWindow {
searchField.enabled = true;
searchDebounceTimer.stop(); // Stop any pending search
updateFilteredModel();
Qt.callLater(function() {
searchField.forceActiveFocus();
});
}
function hide() {
@@ -461,6 +458,17 @@ PanelWindow {
onTextEdited: {
searchDebounceTimer.restart();
}
Connections {
target: launcher
function onVisibleChanged() {
if (launcher.visible) {
searchField.forceActiveFocus();
} else {
searchField.clearFocus();
}
}
}
Keys.onPressed: function(event) {
if ((event.key === Qt.Key_Return || event.key === Qt.Key_Enter) && filteredModel.count && text.length > 0) {
// Launch first app when typing in search field

View File

@@ -15,7 +15,6 @@ DankModal {
property var clipboardEntries: []
property string searchText: ""
property bool shouldFocusSearch: false
function updateFilteredModel() {
filteredClipboardModel.clear();
@@ -118,13 +117,6 @@ DankModal {
height: 550
keyboardFocus: "ondemand"
onVisibleChanged: {
if (visible) {
refreshClipboard();
shouldFocusSearch = true;
}
}
onBackgroundClicked: {
hide();
}
@@ -202,10 +194,10 @@ DankModal {
Connections {
target: clipboardHistory
function onOpened() {
if (shouldFocusSearch) {
searchField.forceActiveFocus()
shouldFocusSearch = false
searchField.forceActiveFocus();
}
function onDialogClosed() {
searchField.clearFocus();
}
}
}

View File

@@ -53,8 +53,6 @@ DankModal {
}
property string searchQuery: ""
property bool shouldFocusSearch: false
function updateFilteredApps() {
filteredApps = [];
selectedIndex = 0;
@@ -216,10 +214,6 @@ DankModal {
}
}
onOpened: {
shouldFocusSearch = true;
}
onBackgroundClicked: {
spotlightOpen = false;
}
@@ -420,7 +414,6 @@ DankModal {
showClearButton: true
textColor: Theme.surfaceText
font.pixelSize: Theme.fontSizeLarge
focus: false
enabled: spotlightOpen
placeholderText: "Search applications..."
text: searchQuery
@@ -432,11 +425,10 @@ DankModal {
Connections {
target: spotlightLauncher
function onOpened() {
if (shouldFocusSearch) {
searchField.forceActiveFocus()
searchField.selectAll()
shouldFocusSearch = false
searchField.forceActiveFocus();
}
function onDialogClosed() {
searchField.clearFocus();
}
}

View File

@@ -16,10 +16,6 @@ DankModal {
height: 230
keyboardFocus: "ondemand"
onOpened: {
passwordInput.forceActiveFocus()
}
onVisibleChanged: {
if (!visible) {
wifiPasswordInput = "";
@@ -100,6 +96,16 @@ DankModal {
onTextEdited: {
wifiPasswordInput = text;
}
Connections {
target: root
function onOpened() {
passwordInput.forceActiveFocus();
}
function onDialogClosed() {
passwordInput.clearFocus();
}
}
onAccepted: {
WifiService.connectToWifiWithPassword(wifiPasswordSSID, passwordInput.text);
wifiPasswordDialogVisible = false;

View File

@@ -199,11 +199,14 @@ PanelWindow {
// Keyboard handling
FocusScope {
id: focusScope
anchors.fill: parent
focus: visible && root.closeOnEscapeKey
Keys.onEscapePressed: {
visible: root.visible // Only active when the modal is visible
Keys.onEscapePressed: (event) => {
if (root.closeOnEscapeKey) {
visible = false
root.visible = false;
event.accepted = true;
}
}
}

View File

@@ -83,6 +83,10 @@ Rectangle {
textInput.cut();
}
function clearFocus() {
textInput.focus = false;
}
// Default styling
width: 200
height: 48