aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJairo Correa <jn.j41r0@gmail.com>2022-10-11 05:22:46 +0000
committerAUTOMATIC1111 <16777216c@gmail.com>2022-10-11 06:32:03 +0000
commit8b7d3f1bef47bbe048f644ed0d8dd3ad46554045 (patch)
treec6a15d0962efd4418bd8a68a341becc01e7f3731
parent42bf5fa3256bff5e4640e5a626e750d4e49e01e1 (diff)
downloadstable-diffusion-webui-gfx803-8b7d3f1bef47bbe048f644ed0d8dd3ad46554045.tar.gz
stable-diffusion-webui-gfx803-8b7d3f1bef47bbe048f644ed0d8dd3ad46554045.tar.bz2
stable-diffusion-webui-gfx803-8b7d3f1bef47bbe048f644ed0d8dd3ad46554045.zip
Make the ctrl+enter shortcut use the generate button on the current tab
-rw-r--r--modules/ui.py2
-rw-r--r--script.js11
2 files changed, 10 insertions, 3 deletions
diff --git a/modules/ui.py b/modules/ui.py
index e8039d76..cafda884 100644
--- a/modules/ui.py
+++ b/modules/ui.py
@@ -1331,7 +1331,7 @@ Requested path was: {f}
with gr.Tabs() as tabs:
for interface, label, ifid in interfaces:
- with gr.TabItem(label, id=ifid):
+ with gr.TabItem(label, id=ifid, elem_id='tab_' + ifid):
interface.render()
if os.path.exists(os.path.join(script_path, "notification.mp3")):
diff --git a/script.js b/script.js
index a92c0f77..9543cbe6 100644
--- a/script.js
+++ b/script.js
@@ -6,6 +6,10 @@ function get_uiCurrentTab() {
return gradioApp().querySelector('.tabs button:not(.border-transparent)')
}
+function get_uiCurrentTabContent() {
+ return gradioApp().querySelector('.tabitem[id^=tab_]:not([style*="display: none"])')
+}
+
uiUpdateCallbacks = []
uiTabChangeCallbacks = []
let uiCurrentTab = null
@@ -50,8 +54,11 @@ document.addEventListener("DOMContentLoaded", function() {
} else if (e.keyCode !== undefined) {
if((e.keyCode == 13 && (e.metaKey || e.ctrlKey))) handled = true;
}
- if (handled) {
- gradioApp().querySelector("#txt2img_generate").click();
+ if (handled) {
+ button = get_uiCurrentTabContent().querySelector('button[id$=_generate]');
+ if (button) {
+ button.click();
+ }
e.preventDefault();
}
})