mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
UI: Replace shift_down code with builtin event.shiftKey
Keeping a global variable that tracks shift is worse because it can get desynced if you leave the window while holding shift (which apparently happens a lot more than you would think)
This commit is contained in:
@@ -58,7 +58,6 @@ var rename_return_emit_name = "popup_rename";
|
|||||||
var popup_rows = [];
|
var popup_rows = [];
|
||||||
var popup_style = "";
|
var popup_style = "";
|
||||||
var popup_sort = {};
|
var popup_sort = {};
|
||||||
var shift_down = false;
|
|
||||||
var world_info_data = {};
|
var world_info_data = {};
|
||||||
var world_info_folder_data = {};
|
var world_info_folder_data = {};
|
||||||
var saved_settings = {};
|
var saved_settings = {};
|
||||||
@@ -4925,49 +4924,44 @@ function getCookie(cname, default_return=null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function detect_enter_submit(e) {
|
function detect_enter_submit(e) {
|
||||||
if (((e.code == "Enter") || (e.code == "NumpadEnter")) && !(shift_down)) {
|
if (e.shiftKey) return;
|
||||||
if (typeof e.stopPropagation != "undefined") {
|
if (!["Enter", "NumpadEnter"].includes(e.key)) return;
|
||||||
e.stopPropagation();
|
|
||||||
} else {
|
if (typeof e.stopPropagation != "undefined") {
|
||||||
e.cancelBubble = true;
|
e.stopPropagation();
|
||||||
}
|
} else {
|
||||||
//console.log("submitting");
|
e.cancelBubble = true;
|
||||||
document.getElementById("btnsubmit").onclick();
|
|
||||||
setTimeout(function() {document.getElementById('input_text').value = '';}, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//console.log("submitting");
|
||||||
|
document.getElementById("btnsubmit").onclick();
|
||||||
|
setTimeout(function() {document.getElementById('input_text').value = '';}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function detect_enter_text(e) {
|
function detect_enter_text(e) {
|
||||||
if (((e.code == "Enter") || (e.code == "NumpadEnter")) && !(shift_down)) {
|
if (e.shiftKey) return;
|
||||||
if (typeof e.stopPropagation != "undefined") {
|
if (!["Enter", "NumpadEnter"].includes(e.key)) return;
|
||||||
e.stopPropagation();
|
|
||||||
} else {
|
if (typeof e.stopPropagation != "undefined") {
|
||||||
e.cancelBubble = true;
|
e.stopPropagation();
|
||||||
}
|
} else {
|
||||||
//get element
|
e.cancelBubble = true;
|
||||||
//console.log("Doing Text Enter");
|
}
|
||||||
//console.log(e.currentTarget.activeElement);
|
//get element
|
||||||
if (e.currentTarget.activeElement != undefined) {
|
//console.log("Doing Text Enter");
|
||||||
var item = $(e.currentTarget.activeElement);
|
//console.log(e.currentTarget.activeElement);
|
||||||
item.onchange();
|
if (e.currentTarget.activeElement != undefined) {
|
||||||
}
|
var item = $(e.currentTarget.activeElement);
|
||||||
|
item.onchange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function detect_key_down(e) {
|
function detect_key_down(e) {
|
||||||
if ((e.code == "ShiftLeft") || (e.code == "ShiftRight")) {
|
if (e.code == "Escape") {
|
||||||
shift_down = true;
|
|
||||||
} else if (e.code == "Escape") {
|
|
||||||
close_menus();
|
close_menus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function detect_key_up(e) {
|
|
||||||
if ((e.code == "ShiftLeft") || (e.code == "ShiftRight")) {
|
|
||||||
shift_down = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectTab(tab) {
|
function selectTab(tab) {
|
||||||
let tabTarget = document.getElementById(tab.getAttribute("tab-target"));
|
let tabTarget = document.getElementById(tab.getAttribute("tab-target"));
|
||||||
let tabClass = Array.from(tab.classList).filter((c) => c.startsWith("tab-"))[0];
|
let tabClass = Array.from(tab.classList).filter((c) => c.startsWith("tab-"))[0];
|
||||||
@@ -5935,7 +5929,6 @@ function openClubImport() {
|
|||||||
//// INIT ////
|
//// INIT ////
|
||||||
|
|
||||||
document.onkeydown = detect_key_down;
|
document.onkeydown = detect_key_down;
|
||||||
document.onkeyup = detect_key_up;
|
|
||||||
document.getElementById("input_text").onkeydown = detect_enter_submit;
|
document.getElementById("input_text").onkeydown = detect_enter_submit;
|
||||||
|
|
||||||
/* -- Popups -- */
|
/* -- Popups -- */
|
||||||
|
Reference in New Issue
Block a user