feat: auto on-screen keyboard #85

This commit is contained in:
leukipp
2025-09-30 21:26:39 +02:00
parent b2b87888e4
commit 4bcb2c4e89
2 changed files with 22 additions and 18 deletions
+10 -6
View File
@@ -132,7 +132,7 @@
</li>
<li class="separator"></li>
<li class="dynamic">
<input id="url" type="text" spellcheck="false" />
<input id="url" type="text" spellcheck="false" readonly="true" />
</li>
<li class="separator"></li>
<li>
@@ -208,16 +208,20 @@
ipcRenderer.on("button-hidden", (e, button) => {
document.getElementById(button.id).parentNode.classList.toggle("hidden", button.hidden);
});
ipcRenderer.on("input-blur", (e, input) => {
document.getElementById(input.id).blur();
});
ipcRenderer.on("input-select", (e, input) => {
document.getElementById(input.id).select();
ipcRenderer.on("input-readonly", (e, input) => {
document.getElementById(input.id).readOnly = input.readonly;
});
ipcRenderer.on("input-text", (e, input) => {
document.getElementById(input.id).value = input.text;
document.getElementById(input.id).placeholder = input.placeholder;
});
ipcRenderer.on("input-select", (e, input) => {
if (input.select) {
document.getElementById(input.id).select();
} else {
window.getSelection()?.removeAllRanges();
}
});
ipcRenderer.on("data-theme", (e, data) => {
document.documentElement.setAttribute("data-theme", data.theme);
});
+11 -11
View File
@@ -263,6 +263,10 @@ const updateNavigation = () => {
text: currentUrl.startsWith("data:") ? "" : currentUrl,
placeholder: defaultUrl.startsWith("data:") ? "" : defaultUrl,
});
WEBVIEW.navigation.webContents.send("input-readonly", {
id: "url",
readonly: !!HARDWARE.support.keyboardVisibility,
});
// Disable zoom buttons
WEBVIEW.navigation.webContents.send("button-disabled", {
@@ -632,22 +636,17 @@ const navigationEvents = async () => {
return;
}
// Handle navigation blur events
let selected = false;
WEBVIEW.navigation.webContents.on("blur", () => {
const visibility = hardware.getKeyboardVisibility();
if (visibility === "ON" && selected) {
WEBVIEW.navigation.webContents.send("input-blur", { id: "url" });
}
});
// Handle input blur events
let selected = false;
ipcMain.on("input-blur", (e, input) => {
const visibility = hardware.getKeyboardVisibility();
switch (input.id) {
case "url":
if (visibility === "ON" && selected) {
hardware.setKeyboardVisibility("OFF");
hardware.setKeyboardVisibility("OFF", () => {
WEBVIEW.navigation.webContents.send("input-select", { id: "url", select: false });
WEBVIEW.navigation.webContents.send("input-readonly", { id: "url", readonly: true });
});
}
break;
}
@@ -664,7 +663,8 @@ const navigationEvents = async () => {
setTimeout(() => {
selected = true;
WEBVIEW.navigation.webContents.focus();
WEBVIEW.navigation.webContents.send("input-select", { id: "url" });
WEBVIEW.navigation.webContents.send("input-select", { id: "url", select: true });
WEBVIEW.navigation.webContents.send("input-readonly", { id: "url", readonly: false });
}, 400);
});
}