Merge pull request #269 from one-some/ui2-shortcut-fix

Shortcut fix
This commit is contained in:
ebolam
2022-10-30 12:49:33 -04:00
committed by GitHub

View File

@@ -109,9 +109,9 @@ const context_menu_actions = [
const shortcuts = [ const shortcuts = [
{key: "k", desc: "Finder", func: open_finder}, {key: "k", desc: "Finder", func: open_finder},
{key: "/", desc: "Help screen", func: () => openPopup("shortcuts-popup")}, {key: "/", desc: "Help screen", func: () => openPopup("shortcuts-popup")},
{key: "z", desc: "Undoes last story action", func: () => socket.emit("back", {})}, {key: "z", desc: "Undoes last story action", func: () => socket.emit("back", {}), criteria: canNavigateStoryHistory},
{key: "y", desc: "Redoes last story action", func: () => socket.emit("redo", {})}, {key: "y", desc: "Redoes last story action", func: () => socket.emit("redo", {}), criteria: canNavigateStoryHistory},
{key: "e", desc: "Retries last story action", func: () => socket.emit("retry", {})}, {key: "e", desc: "Retries last story action", func: () => socket.emit("retry", {}), criteria: canNavigateStoryHistory},
{key: "m", desc: "Focuses Memory", func: () => focusEl("#memory")}, {key: "m", desc: "Focuses Memory", func: () => focusEl("#memory")},
{key: "l", desc: "Focuses Author's Note", func: () => focusEl("#authors_notes")}, // CTRL-N is reserved :^( {key: "l", desc: "Focuses Author's Note", func: () => focusEl("#authors_notes")}, // CTRL-N is reserved :^(
{key: "g", desc: "Focuses game text", func: () => focusEl("#input_text")}, {key: "g", desc: "Focuses game text", func: () => focusEl("#input_text")},
@@ -5489,6 +5489,7 @@ function initalizeTooltips() {
for (const shortcut of shortcuts) { for (const shortcut of shortcuts) {
if (shortcut.key !== event.key) continue; if (shortcut.key !== event.key) continue;
if (shortcut.criteria && !shortcut.criteria()) continue;
event.preventDefault(); event.preventDefault();
shortcut.func(); shortcut.func();
} }
@@ -5527,7 +5528,9 @@ function reportError(title, text) {
showNotification(title, text, "error"); showNotification(title, text, "error");
} }
showNotification("Be aware!", "Things are happening at an alarming pace!"); function canNavigateStoryHistory() {
return !["TEXTAREA", "INPUT"].includes(document.activeElement.tagName);
}
//function to load more actions if nessisary //function to load more actions if nessisary
function infinite_scroll() { function infinite_scroll() {