From 0cf59a764990de4ffebb3a34d257bf51d3e41d99 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 15 Nov 2026 09:52:48 -0800 Subject: [PATCH 01/17] Shortcuts: a tool or command can have a hold shortcut that runs when its key is held MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Edit › Keyboard Shortcuts gets a Hold Shortcuts checkbox, off by default, with a ? button that explains it. While it is off, the dialog has no Hold column and every key runs on its press as before. While it is on, the dialog shows a Hold column and the Hold Shortcut Delay (`keyHoldDelay`, 0.35 s, 0.2 to 1.0 s), and a letter, digit or punctuation key, alone or with Shift, can hold a tool or command. Held for the delay, the key runs its hold shortcut once and its repeats are ignored until it is let go; a quicker press runs what the key runs without one, at the release. Another key, or Cmd, Ctrl or Alt, ends the wait first; focus loss, a dialog, a text field, Presentation Mode or an input method composition ends it without running anything. A hold on a letter alone leaves the letter with Shift as it is, and a key the active tool uses itself (E with the Extend Path tool) does not wait. A tool key with a hold shortcut runs the hold instead of choosing its tool temporarily (`holdToolKeys`). Preferences › General › Options lists both settings too, with the delay dimmed while Hold Shortcuts is off. Hold shortcuts are stored apart from the shortcuts (`shortcut_holds`). `shortcuts.set` takes `hold`, `shortcuts.list` rows have `hold`, `shortcuts.conflicts` lists hold clashes, Export… writes `holds` and Import… reads it, and Export Text… adds a `Hold X` column while the checkbox is on. Reset to Defaults and the presets clear them. The new strings have rows in every catalog. --- crates/engine/src/cmd/prefscmds.rs | 2 + crates/engine/src/lib.rs | 2 +- crates/engine/src/prefs.rs | 24 + crates/engine/src/tests/prefs_file.rs | 21 + crates/mcp/src/ui_catalog.rs | 11 +- crates/ui-egui/src/app.rs | 1 + crates/ui-egui/src/i18n/bg.tsv | 10 + crates/ui-egui/src/i18n/bs.tsv | 10 + crates/ui-egui/src/i18n/ca.tsv | 10 + crates/ui-egui/src/i18n/cs.tsv | 10 + crates/ui-egui/src/i18n/da.tsv | 10 + crates/ui-egui/src/i18n/de.tsv | 10 + crates/ui-egui/src/i18n/el.tsv | 10 + crates/ui-egui/src/i18n/es.tsv | 10 + crates/ui-egui/src/i18n/fi.tsv | 10 + crates/ui-egui/src/i18n/fr.tsv | 10 + crates/ui-egui/src/i18n/gu.tsv | 10 + crates/ui-egui/src/i18n/hi.tsv | 10 + crates/ui-egui/src/i18n/hu.tsv | 10 + crates/ui-egui/src/i18n/id.tsv | 10 + crates/ui-egui/src/i18n/it.tsv | 10 + crates/ui-egui/src/i18n/ja.tsv | 10 + crates/ui-egui/src/i18n/ka.tsv | 10 + crates/ui-egui/src/i18n/ko.tsv | 10 + crates/ui-egui/src/i18n/nl.tsv | 10 + crates/ui-egui/src/i18n/pl.tsv | 10 + crates/ui-egui/src/i18n/pt-br.tsv | 10 + crates/ui-egui/src/i18n/ru.tsv | 10 + crates/ui-egui/src/i18n/sv.tsv | 10 + crates/ui-egui/src/i18n/tr.tsv | 10 + crates/ui-egui/src/i18n/uk.tsv | 10 + crates/ui-egui/src/i18n/vi.tsv | 10 + crates/ui-egui/src/i18n/zh-hans.tsv | 10 + crates/ui-egui/src/i18n/zh-hant.tsv | 10 + crates/ui-egui/src/lib.rs | 3 + crates/ui-egui/src/menus/ui_commands.rs | 11 +- crates/ui-egui/src/prefs_dialog.rs | 12 + crates/ui-egui/src/prefs_dialog/tests.rs | 39 ++ crates/ui-egui/src/shortcut_editor.rs | 539 +++++++++++++++++- crates/ui-egui/src/shortcuts.rs | 89 ++- crates/ui-egui/src/shortcuts/hold_keys.rs | 321 +++++++++++ .../ui-egui/src/shortcuts/hold_keys/tests.rs | 517 +++++++++++++++++ crates/ui-egui/src/state.rs | 7 + docs/mcp.md | 32 +- docs/target-app-parity.md | 1 + 45 files changed, 1849 insertions(+), 63 deletions(-) create mode 100644 crates/ui-egui/src/shortcuts/hold_keys.rs create mode 100644 crates/ui-egui/src/shortcuts/hold_keys/tests.rs diff --git a/crates/engine/src/cmd/prefscmds.rs b/crates/engine/src/cmd/prefscmds.rs index b6c500749f..d255558e7b 100644 --- a/crates/engine/src/cmd/prefscmds.rs +++ b/crates/engine/src/cmd/prefscmds.rs @@ -156,6 +156,8 @@ pub const PREF_SPECS: &[PrefSpec] = &[ p!("scrubNumericFields", "General", "Options", "Scrub Numeric Fields by Dragging", bool), p!("trackpadRotateView", "General", "Options", "Trackpad Gesture to Rotate View", bool), p!("holdToolKeys", "General", "Options", "Hold a Tool Shortcut to Use the Tool Temporarily", bool), + p!("holdShortcuts", "General", "Options", "Hold Shortcuts", bool), + p!("keyHoldDelay", "General", "Options", "Hold Shortcut Delay", num(0.2, 1.0, "s")), p!("boundingBoxWhileMovingAndDrawing", "General", "Options", "Show Bounding Box While Moving and Drawing", bool), // Selection & Anchor Display p!("selectionTolerance", "Selection & Anchor Display", "Selection", "Tolerance", num(1.0, 8.0, "px")), diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index aeb723c963..2b89a31966 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -408,7 +408,7 @@ use history::history_budget_for; pub use history::{History, HistoryEntry, NamedStep, default_history_budget}; pub(crate) use interaction::PreviewCopies; pub use interaction::{Interaction, LastTransform, UndoGroup, UndoScope}; -pub use prefs::{DrawMode, Prefs}; +pub use prefs::{DrawMode, KEY_HOLD_DELAY, KEY_HOLD_DELAY_RANGE, Prefs}; pub use sanity::TOO_DEEP; pub(crate) use sanity::{deselect_hidden, is_guide_path}; #[cfg(test)] diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs index 86525e9214..710604e524 100644 --- a/crates/engine/src/prefs.rs +++ b/crates/engine/src/prefs.rs @@ -71,6 +71,13 @@ pub struct Prefs { /// A single-key tool shortcut held down chooses its tool until the key is let go, and then the /// tool active before comes back; a quick press chooses the tool for good. pub hold_tool_keys: bool, + /// Hold shortcuts act (Edit › Keyboard Shortcuts › Hold Shortcuts, off by default): a key with a + /// hold shortcut runs it when held for [`Self::key_hold_delay`], and its own shortcut when let go + /// sooner. Off, every key runs on its press and the dialog shows no Hold column. + pub hold_shortcuts: bool, + /// Seconds a key with a hold shortcut must stay down before the hold shortcut runs (Hold + /// Shortcut Delay, 0.2 to 1.0). VectorCraft's own default, 0.35. + pub key_hold_delay: f64, /// With View › Show Bounding Box on, the bounding box stays visible while a drag moves the /// selection, and the shape tools that show it draw it around the shape being drawn. Off (the /// default), it hides during a move and while a shape is drawn, except that a Selection tool @@ -385,6 +392,21 @@ pub struct Prefs { pub import_matches: Vec, } +/// The default Hold Shortcut Delay, in seconds (VectorCraft's own value). +pub const KEY_HOLD_DELAY: f64 = 0.35; +/// The range of the Hold Shortcut Delay, in seconds. +pub const KEY_HOLD_DELAY_RANGE: (f64, f64) = (0.2, 1.0); + +impl Prefs { + /// The Hold Shortcut Delay in seconds, inside its range. A restored settings file is not + /// checked against the range, so a value outside it is brought inside, and one that is not a + /// number gives the default. + pub fn key_hold_delay(&self) -> f64 { + let (min, max) = KEY_HOLD_DELAY_RANGE; + if self.key_hold_delay.is_finite() { self.key_hold_delay.clamp(min, max) } else { KEY_HOLD_DELAY } + } +} + impl Default for Prefs { fn default() -> Self { let s = |v: &str| v.to_string(); @@ -415,6 +437,8 @@ impl Default for Prefs { scrub_numeric_fields: true, trackpad_rotate_view: true, hold_tool_keys: true, + hold_shortcuts: false, + key_hold_delay: KEY_HOLD_DELAY, bounding_box_while_moving_and_drawing: false, paste_offset: 10.0, selection_tolerance: 3.0, diff --git a/crates/engine/src/tests/prefs_file.rs b/crates/engine/src/tests/prefs_file.rs index c2822ba937..bfe98b901b 100644 --- a/crates/engine/src/tests/prefs_file.rs +++ b/crates/engine/src/tests/prefs_file.rs @@ -176,3 +176,24 @@ fn a_file_over_the_limit_is_refused_before_it_is_parsed() { assert!(s.execute("prefs.import", &json!({"path": missing.to_string_lossy()})).is_err()); assert_eq!(s.prefs.to_json().to_string(), before); } + +/// Hold Shortcuts is off by default. The Hold Shortcut Delay takes 0.2 to 1.0 s and refuses other +/// values; a value from a settings file outside the range is brought inside it. +#[test] +fn hold_shortcut_preferences() { + let mut s = Session::new(); + assert!(!s.prefs.hold_shortcuts); + assert_eq!(s.prefs.key_hold_delay(), 0.35); + for ok in [0.2, 1.0] { + s.execute("prefs.set", &json!({"key": "keyHoldDelay", "value": ok})).unwrap(); + assert_eq!(s.prefs.key_hold_delay(), ok); + } + for bad in [0.1, 1.5] { + assert!(is_bad_params(s.execute("prefs.set", &json!({"key": "keyHoldDelay", "value": bad}))), "{bad}"); + } + s.execute("prefs.set", &json!({"key": "holdShortcuts", "value": true})).unwrap(); + assert!(s.prefs.hold_shortcuts); + let restored: Prefs = serde_json::from_value(json!({"keyHoldDelay": 5.0})).unwrap(); + assert_eq!(restored.key_hold_delay(), 1.0); + assert!(!restored.hold_shortcuts); +} diff --git a/crates/mcp/src/ui_catalog.rs b/crates/mcp/src/ui_catalog.rs index 8e651622af..3774177db0 100644 --- a/crates/mcp/src/ui_catalog.rs +++ b/crates/mcp/src/ui_catalog.rs @@ -173,8 +173,13 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "Cmd+I", "{} open the Check Spelling dialog to walk through unrecognized words with suggestions, ignore, change and dictionary options", ), - ("shortcuts.set", "Set Keyboard Shortcut", "", "{id: command id or tool:, shortcut: \"Cmd+Shift+K\" | \"\" (none) | null (default), force?}"), - ("shortcuts.list", "List Keyboard Shortcuts", "", "{query?} → [{id, label, group, shortcut, default, overridden}]"), + ( + "shortcuts.set", + "Set Keyboard Shortcut", + "", + "{id: command id or tool:, shortcut?: \"Cmd+Shift+K\" | \"\" (none) | null (default), hold?: a character key alone or with Shift (\"X\", \"Shift+X\", \".\") | \"\" | null (none), force?} → {id, shortcut, hold, removedFrom}; `hold` alone leaves the shortcut as it is; a hold shortcut acts while the holdShortcuts preference is on", + ), + ("shortcuts.list", "List Keyboard Shortcuts", "", "{query?} → [{id, label, group, shortcut, hold, default, overridden}]"), ("shortcuts.conflicts", "Keyboard Shortcut Conflicts", "", "{} → [{shortcut, ids}]"), ("shortcuts.reset", "Reset Keyboard Shortcuts", "", "{}"), ( @@ -188,7 +193,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "shortcuts.exportText", "Export Keyboard Shortcuts as Text…", "", - "{path?} save the current set's tools and menu commands with their shortcuts as a UTF-8 text file (Keyboard Shortcuts › Export Text…): the set's name, then a Tools and a Menu Commands section in the dialog's order, one `nameshortcut` line per row, empty after the tab when it has none; without `path`, pick a file", + "{path?} save the current set's tools and menu commands with their shortcuts as a UTF-8 text file (Keyboard Shortcuts › Export Text…): the set's name, then a Tools and a Menu Commands section in the dialog's order, one `nameshortcut` line per row, empty after the tab when it has none, and while the holdShortcuts preference is on a third `Hold ` column on a row with a hold shortcut; without `path`, pick a file", ), ("shortcuts.import", "Import Keyboard Shortcuts…", "", "{path? | data?}"), ( diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index f708d0f454..e5f5cfc91c 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -191,6 +191,7 @@ impl VectorcraftApp { input_frames: vec![], shortcuts_frames: vec![], held_tool: Vec::new(), + hold_keys: Default::default(), synthetic_injected: false, injected_events: vec![], injected_generation: InputGeneration::default(), diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index a6a69d9100..8b4fba95fc 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -7018,3 +7018,13 @@ breakText Glyphs Глифи Open a document to mark its fold lines. Отворете документ, за да отбележите линиите му на сгъване. Remove Fold Line Role Премахни вида на линията @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" composer трябва да е "singleLine", "everyLine", "standardSingleLine" или "standardEveryLine" + Tap Кратко натискане + Clear Hold Изчистване на задържането + Hold Shortcuts Комбинации със задържане + Hold Shortcut Delay Забавяне на комбинациите със задържане + How hold shortcuts work Как работят комбинациите със задържане + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. Щракнете и натиснете клавиш, който да се задържа за това (Esc отменя). Задържането на клавиша изпълнява това; краткото натискане изпълнява собствената комбинация на клавиша. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. Краткото натискане на клавиш изпълнява неговата комбинация. Задържането на клавиша за времето на забавяне изпълнява вместо това инструмента или командата от колоната му „Задръжте“. Комбинация със задържане е клавиш с буква, цифра или препинателен знак, самостоятелно или с Shift. +@msg Hold {_1} is already used by {_2} Задържането на {_1} вече се използва от {_2} +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) комбинация със задържане е клавиш, който въвежда знак, самостоятелно или с Shift ({shown} съдържа Cmd, Ctrl или Alt) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} не може да бъде комбинация със задържане: използвайте буква, цифра или препинателен знак diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index 5da48b6cff..bbfca4e045 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -7071,3 +7071,13 @@ shape Open Otvoren Open a document to mark its fold lines. Otvorite dokument da označite njegove linije savijanja. Remove Fold Line Role Ukloni vrstu linije @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" composer mora biti "singleLine", "everyLine", "standardSingleLine" ili "standardEveryLine" + Tap Kratki pritisak + Clear Hold Očisti zadržavanje + Hold Shortcuts Prečice zadržavanjem + Hold Shortcut Delay Kašnjenje prečica zadržavanjem + How hold shortcuts work Kako rade prečice zadržavanjem + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. Kliknite, zatim pritisnite tipku koju treba zadržati za ovo (Esc otkazuje). Zadržavanje tipke pokreće ovo; kratki pritisak pokreće vlastitu prečicu tipke. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. Kratki pritisak tipke pokreće njenu prečicu. Zadržavanje tipke tokom kašnjenja umjesto toga pokreće alat ili naredbu iz njene kolone Zadrži. Prečica zadržavanjem je tipka sa slovom, cifrom ili interpunkcijskim znakom, sama ili sa Shift. +@msg Hold {_1} is already used by {_2} Zadržavanje {_1} već koristi {_2} +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) prečica zadržavanjem je tipka koja upisuje znak, sama ili sa Shift ({shown} ima Cmd, Ctrl ili Alt) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} ne može biti prečica zadržavanjem: koristite slovo, cifru ili interpunkcijsku tipku diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index e861e61fec..91f334b451 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -7793,3 +7793,13 @@ breakText Glyphs Glifs Open a document to mark its fold lines. Obre un document per marcar-ne les línies de plegat. Remove Fold Line Role Elimina el tipus de línia @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" composer ha de ser "singleLine", "everyLine", "standardSingleLine" o "standardEveryLine" + Tap Pulsació breu + Clear Hold Esborra la pulsació llarga + Hold Shortcuts Dreceres de pulsació llarga + Hold Shortcut Delay Retard de les dreceres de pulsació llarga + How hold shortcuts work Com funcionen les dreceres de pulsació llarga + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. Fes clic i prem una tecla per mantenir premuda per a això (Esc cancel·la). Mantenir premuda la tecla executa això; una pulsació breu executa la drecera pròpia de la tecla. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. Una pulsació breu d’una tecla executa la seva drecera. Mantenir premuda la tecla durant el retard executa en canvi l’eina o l’ordre de la seva columna Mantén. Una drecera de pulsació llarga és una tecla de lletra, xifra o puntuació, sola o amb Shift. +@msg Hold {_1} is already used by {_2} La pulsació llarga de {_1} ja la fa servir {_2} +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) una drecera de pulsació llarga és una tecla que escriu un caràcter, sola o amb Shift ({shown} té Cmd, Ctrl o Alt) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} no pot ser una drecera de pulsació llarga: fes servir una lletra, una xifra o una tecla de puntuació diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 1a4d359b93..eacda6ef61 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -9613,3 +9613,13 @@ breakText Glyphs Glyfy No objects are selected. Nejsou vybrány žádné objekty. Open a document to mark its fold lines. Otevřete dokument, abyste označili jeho linie skladu. Remove Fold Line Role Odstranit typ linie + Tap Krátký stisk + Clear Hold Vymazat podržení + Hold Shortcuts Zkratky podržením + Hold Shortcut Delay Prodleva zkratek podržením + How hold shortcuts work Jak fungují zkratky podržením + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. Klikněte a stiskněte klávesu, kterou pro toto podržíte (Esc zruší). Podržení klávesy spustí toto; krátký stisk spustí vlastní zkratku klávesy. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. Krátký stisk klávesy spustí její zkratku. Podržení klávesy po dobu prodlevy místo toho spustí nástroj nebo příkaz z jejího sloupce Podržení. Zkratka podržením je klávesa s písmenem, číslicí nebo interpunkcí, samotná nebo se Shiftem. +@msg Hold {_1} is already used by {_2} Podržení {_1} už používá {_2} +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) zkratka podržením je klávesa, která píše znak, samotná nebo se Shiftem ({shown} obsahuje Cmd, Ctrl nebo Alt) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} nemůže být zkratkou podržením: použijte písmeno, číslici nebo interpunkční klávesu diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 723766f020..5ba395314d 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -7703,3 +7703,13 @@ breakText Glyphs Glyffer Open a document to mark its fold lines. Åbn et dokument for at markere dets foldelinjer. Remove Fold Line Role Fjern linjetype @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" composer skal være "singleLine", "everyLine", "standardSingleLine" eller "standardEveryLine" + Tap Kort tryk + Clear Hold Ryd hold + Hold Shortcuts Holdegenveje + Hold Shortcut Delay Forsinkelse for holdegenveje + How hold shortcuts work Sådan virker holdegenveje + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. Klik, og tryk derefter på en tast, der skal holdes nede for dette (Esc annullerer). Når tasten holdes nede, køres dette; et kort tryk kører tastens egen genvej. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. Et kort tryk på en tast kører dens genvej. Når tasten holdes nede i forsinkelsens varighed, køres i stedet værktøjet eller kommandoen i dens Hold-kolonne. En holdegenvej er en bogstav-, ciffer- eller tegnsætningstast, alene eller med Shift. +@msg Hold {_1} is already used by {_2} Hold {_1} bruges allerede af {_2} +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) en holdegenvej er en tast, der skriver et tegn, alene eller med Shift ({shown} har Cmd, Ctrl eller Alt) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} kan ikke være en holdegenvej: brug et bogstav, et ciffer eller en tegnsætningstast diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 21a07e09e5..113b51e3bd 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -9211,3 +9211,13 @@ breakText Glyphs Glyphen No objects are selected. Es sind keine Objekte ausgewählt. Open a document to mark its fold lines. Öffnen Sie ein Dokument, um seine Faltlinien festzulegen. Remove Fold Line Role Linienart entfernen + Tap Kurz drücken + Clear Hold Halten löschen + Hold Shortcuts Halte-Tastaturbefehle + Hold Shortcut Delay Verzögerung für Halte-Tastaturbefehle + How hold shortcuts work So funktionieren Halte-Tastaturbefehle + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. Klicken Sie und drücken Sie dann eine Taste, die hierfür gehalten werden soll (Esc bricht ab). Halten der Taste führt dies aus; kurzes Drücken führt den eigenen Tastaturbefehl der Taste aus. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. Kurzes Drücken einer Taste führt ihren Tastaturbefehl aus. Halten der Taste für die Dauer der Verzögerung führt stattdessen das Werkzeug oder den Befehl in ihrer Spalte „Halten“ aus. Ein Halte-Tastaturbefehl ist eine Buchstaben-, Ziffern- oder Satzzeichentaste, allein oder mit Shift. +@msg Hold {_1} is already used by {_2} Halten {_1} wird bereits von {_2} verwendet +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) Ein Halte-Tastaturbefehl ist eine Taste, die ein Zeichen eingibt, allein oder mit Shift ({shown} enthält Cmd, Ctrl oder Alt) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} kann kein Halte-Tastaturbefehl sein: Verwenden Sie einen Buchstaben, eine Ziffer oder eine Satzzeichentaste diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index ebd167f397..62a69a7f97 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -7767,3 +7767,13 @@ breakText Glyphs Γλύφοι Open a document to mark its fold lines. Ανοίξτε ένα έγγραφο για να σημειώσετε τις γραμμές δίπλωσής του. Remove Fold Line Role Αφαίρεση τύπου γραμμής @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" το composer πρέπει να είναι "singleLine", "everyLine", "standardSingleLine" ή "standardEveryLine" + Tap Σύντομο πάτημα + Clear Hold Εκκαθάριση παρατεταμένου πατήματος + Hold Shortcuts Συντομεύσεις παρατεταμένου πατήματος + Hold Shortcut Delay Καθυστέρηση συντομεύσεων παρατεταμένου πατήματος + How hold shortcuts work Πώς λειτουργούν οι συντομεύσεις παρατεταμένου πατήματος + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. Κάντε κλικ και πατήστε ένα πλήκτρο που θα κρατάτε πατημένο για αυτό (Esc για ακύρωση). Το παρατεταμένο πάτημα του πλήκτρου εκτελεί αυτό. Ένα σύντομο πάτημα εκτελεί τη συντόμευση του ίδιου του πλήκτρου. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. Ένα σύντομο πάτημα πλήκτρου εκτελεί τη συντόμευσή του. Αν κρατήσετε πατημένο το πλήκτρο για τον χρόνο καθυστέρησης, εκτελείται αντί γι’ αυτό το εργαλείο ή η εντολή της στήλης «Κρατήστε πατημένο». Μια συντόμευση παρατεταμένου πατήματος είναι ένα πλήκτρο γράμματος, ψηφίου ή σημείου στίξης, μόνο του ή με Shift. +@msg Hold {_1} is already used by {_2} το παρατεταμένο πάτημα του {_1} χρησιμοποιείται ήδη από το {_2} +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) μια συντόμευση παρατεταμένου πατήματος είναι ένα πλήκτρο που πληκτρολογεί έναν χαρακτήρα, μόνο του ή με Shift (το {shown} έχει Cmd, Ctrl ή Alt) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key το {shown} δεν μπορεί να είναι συντόμευση παρατεταμένου πατήματος: χρησιμοποιήστε γράμμα, ψηφίο ή πλήκτρο στίξης diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 27d7d4aaf8..b4df50d6b1 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -7754,3 +7754,13 @@ breakText Glyphs Glifos Open a document to mark its fold lines. Abre un documento para marcar sus líneas de plegado. Remove Fold Line Role Quitar tipo de línea @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" composer debe ser "singleLine", "everyLine", "standardSingleLine" o "standardEveryLine" + Tap Pulsación breve + Clear Hold Borrar pulsación larga + Hold Shortcuts Métodos abreviados de pulsación larga + Hold Shortcut Delay Retardo de pulsación larga + How hold shortcuts work Cómo funcionan los métodos abreviados de pulsación larga + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. Haz clic y presiona una tecla que mantener pulsada para esto (Esc cancela). Mantener pulsada la tecla ejecuta esto; una pulsación breve ejecuta el método abreviado propio de la tecla. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. Una pulsación breve de una tecla ejecuta su método abreviado. Mantener pulsada la tecla durante el retardo ejecuta en su lugar la herramienta o el comando de su columna Mantener pulsado. Un método abreviado de pulsación larga es una tecla de letra, dígito o puntuación, sola o con Shift. +@msg Hold {_1} is already used by {_2} La pulsación larga de {_1} ya la usa {_2} +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) un método abreviado de pulsación larga es una tecla que escribe un carácter, sola o con Shift ({shown} tiene Cmd, Ctrl o Alt) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} no puede ser un método abreviado de pulsación larga: usa una letra, un dígito o una tecla de puntuación diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index 3f29fd7f7a..fca0c1cda1 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -7850,3 +7850,13 @@ breakText Glyphs Merkit Open a document to mark its fold lines. Avaa asiakirja, niin voit merkitä sen taittoviivat. Remove Fold Line Role Poista viivatyyppi @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" composer on oltava "singleLine", "everyLine", "standardSingleLine" tai "standardEveryLine" + Tap Lyhyt painallus + Clear Hold Tyhjennä pitkä painallus + Hold Shortcuts Pitkän painalluksen pikanäppäimet + Hold Shortcut Delay Pitkän painalluksen viive + How hold shortcuts work Näin pitkän painalluksen pikanäppäimet toimivat + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. Napsauta ja paina sitten näppäintä, jota pidetään pohjassa tätä varten (Esc peruuttaa). Näppäimen pitäminen pohjassa suorittaa tämän; lyhyt painallus suorittaa näppäimen oman pikanäppäimen. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. Näppäimen lyhyt painallus suorittaa sen pikanäppäimen. Kun näppäintä pidetään pohjassa viiveen ajan, suoritetaan sen sijaan sen Pidä pohjassa -sarakkeen työkalu tai komento. Pitkän painalluksen pikanäppäin on kirjain-, numero- tai välimerkkinäppäin yksin tai Shiftin kanssa. +@msg Hold {_1} is already used by {_2} Pitkä painallus {_1} on jo käytössä kohteella {_2} +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) pitkän painalluksen pikanäppäin on merkin kirjoittava näppäin yksin tai Shiftin kanssa ({shown} sisältää Cmd-, Ctrl- tai Alt-näppäimen) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} ei voi olla pitkän painalluksen pikanäppäin: käytä kirjainta, numeroa tai välimerkkinäppäintä diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 20e94749c5..e18a7cbda1 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -9598,4 +9598,14 @@ breakText Glyphs Glyphes No objects are selected. Aucun objet n’est sélectionné. Open a document to mark its fold lines. Ouvrez un document pour marquer ses lignes de pliage. Remove Fold Line Role Supprimer le type de ligne + Tap Appui bref + Clear Hold Effacer le maintien + Hold Shortcuts Raccourcis de maintien + Hold Shortcut Delay Délai des raccourcis de maintien + How hold shortcuts work Fonctionnement des raccourcis de maintien + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. Cliquez, puis appuyez sur une touche à maintenir pour cet élément (Échap annule). Maintenir la touche exécute cet élément ; un appui bref exécute le raccourci propre à la touche. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. Un appui bref sur une touche exécute son raccourci. Maintenir la touche pendant le délai exécute à la place l’outil ou la commande de sa colonne Maintenir. Un raccourci de maintien est une touche de lettre, de chiffre ou de ponctuation, seule ou avec Maj. +@msg Hold {_1} is already used by {_2} Le maintien de {_1} est déjà utilisé par {_2} +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) un raccourci de maintien est une touche qui saisit un caractère, seule ou avec Maj ({shown} comporte Cmd, Ctrl ou Alt) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} ne peut pas être un raccourci de maintien : utilisez une lettre, un chiffre ou une touche de ponctuation @msg {_1} × {_2} pixels is too large for GIF (at most 65535 pixels a side): lower the resolution {_1} × {_2} pixels, c’est trop grand pour le GIF (65535 pixels par côté au plus) : réduisez la résolution diff --git a/crates/ui-egui/src/i18n/gu.tsv b/crates/ui-egui/src/i18n/gu.tsv index ff59a464c5..814251df4f 100644 --- a/crates/ui-egui/src/i18n/gu.tsv +++ b/crates/ui-egui/src/i18n/gu.tsv @@ -4798,3 +4798,13 @@ swatch [Registration] [રજિસ્ટ્રેશન] Standard Single-line Composer સ્ટાન્ડર્ડ સિંગલ-લાઇન કમ્પોઝર Standard Every-line Composer સ્ટાન્ડર્ડ એવરી-લાઇન કમ્પોઝર @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" composer આમાંથી એક હોવું જોઈએ: "singleLine", "everyLine", "standardSingleLine" અથવા "standardEveryLine" + Tap ટૂંકું દબાણ + Clear Hold હોલ્ડ સાફ કરો + Hold Shortcuts હોલ્ડ શોર્ટકટ + Hold Shortcut Delay હોલ્ડ શોર્ટકટ વિલંબ + How hold shortcuts work હોલ્ડ શોર્ટકટ કેવી રીતે કામ કરે છે + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. ક્લિક કરો, પછી આ માટે દબાવી રાખવાની કી દબાવો (Esc રદ કરે છે). કી દબાવી રાખવાથી આ ચાલે છે; ટૂંકું દબાણ કીનો પોતાનો શોર્ટકટ ચલાવે છે. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. કીને ટૂંકું દબાવવાથી તેનો શોર્ટકટ ચાલે છે. વિલંબ જેટલો સમય કી દબાવી રાખવાથી તેના બદલે તેની હોલ્ડ કૉલમમાંનું ટૂલ અથવા આદેશ ચાલે છે. હોલ્ડ શોર્ટકટ એ અક્ષર, અંક અથવા વિરામચિહ્નની કી છે, એકલી અથવા Shift સાથે. +@msg Hold {_1} is already used by {_2} હોલ્ડ {_1} પહેલેથી {_2} વાપરે છે +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) હોલ્ડ શોર્ટકટ એ અક્ષર લખતી કી છે, એકલી અથવા Shift સાથે ({shown} માં Cmd, Ctrl અથવા Alt છે) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} હોલ્ડ શોર્ટકટ ન હોઈ શકે: અક્ષર, અંક અથવા વિરામચિહ્નની કી વાપરો diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index 6fe8f254f4..1e37429de3 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -9205,3 +9205,13 @@ theme Appearance अपीयरेंस No objects are selected. कोई ऑब्जेक्ट सिलेक्ट नहीं है। Open a document to mark its fold lines. फ़ोल्ड लाइनें मार्क करने के लिए कोई डॉक्यूमेंट ओपन करें। Remove Fold Line Role लाइन प्रकार हटाएँ + Tap जल्दी दबाना + Clear Hold होल्ड साफ़ करें + Hold Shortcuts होल्ड शॉर्टकट + Hold Shortcut Delay होल्ड शॉर्टकट विलंब + How hold shortcuts work होल्ड शॉर्टकट कैसे काम करते हैं + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. क्लिक करें, फिर इसके लिए दबाए रखने वाली कुंजी दबाएँ (Esc रद्द)। कुंजी दबाए रखने पर यह चलता है; जल्दी से दबाने पर कुंजी का अपना शॉर्टकट चलता है। + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. किसी कुंजी को जल्दी से दबाने पर उसका शॉर्टकट चलता है। कुंजी को विलंब जितनी देर दबाए रखने पर इसके बजाय उसके होल्ड कॉलम का टूल या कमांड चलता है। होल्ड शॉर्टकट कोई अक्षर, अंक या विराम चिह्न वाली कुंजी होती है, अकेले या Shift के साथ। +@msg Hold {_1} is already used by {_2} होल्ड {_1} का उपयोग पहले से ही {_2} द्वारा किया जाता है +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) होल्ड शॉर्टकट ऐसी कुंजी होती है जो अकेले या Shift के साथ कोई कैरेक्टर टाइप करती है ({shown} में Cmd, Ctrl या Alt है) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} होल्ड शॉर्टकट नहीं हो सकता: कोई अक्षर, अंक या विराम चिह्न वाली कुंजी उपयोग करें diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 4a93411b47..d6a795b6b1 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -9601,3 +9601,13 @@ breakText Glyphs Glifák No objects are selected. Nincs kijelölt objektum. Open a document to mark its fold lines. Nyiss meg egy dokumentumot a hajtásvonalai megjelöléséhez. Remove Fold Line Role Vonaltípus eltávolítása + Tap Rövid lenyomás + Clear Hold Nyomva tartás törlése + Hold Shortcuts Nyomva tartásos billentyűparancsok + Hold Shortcut Delay Nyomva tartás késleltetése + How hold shortcuts work Így működnek a nyomva tartásos billentyűparancsok + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. Kattints, majd nyomd le a billentyűt, amelyet ehhez nyomva kell tartani (Esc: mégse). A billentyű nyomva tartása ezt futtatja; a rövid lenyomás a billentyű saját billentyűparancsát futtatja. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. Egy billentyű rövid lenyomása a billentyűparancsát futtatja. Ha a késleltetés idejéig nyomva tartod, helyette a Nyomva tartás oszlopában lévő eszköz vagy parancs fut. Nyomva tartásos billentyűparancs lehet egy betű-, szám- vagy írásjelbillentyű, önmagában vagy Shifttel. +@msg Hold {_1} is already used by {_2} már foglalt: nyomva tartás {_1} (használja: {_2}) +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) a nyomva tartásos billentyűparancs egy karaktert beíró billentyű, önmagában vagy Shifttel ({shown} Cmd, Ctrl vagy Alt billentyűt tartalmaz) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} nem lehet nyomva tartásos billentyűparancs: használj betű-, szám- vagy írásjelbillentyűt diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index bf029526f7..6c30d93fa3 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -7033,3 +7033,13 @@ breakText Glyphs Glif Open a document to mark its fold lines. Buka dokumen untuk menandai garis lipatnya. Remove Fold Line Role Hapus jenis garis @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" composer harus "singleLine", "everyLine", "standardSingleLine", atau "standardEveryLine" + Tap Tekan singkat + Clear Hold Hapus Tahan + Hold Shortcuts Pintasan tahan + Hold Shortcut Delay Jeda pintasan tahan + How hold shortcuts work Cara kerja pintasan tahan + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. Klik, lalu tekan tombol yang ditahan untuk ini (Esc membatalkan). Menahan tombol menjalankan ini; tekan singkat menjalankan pintasan milik tombol itu sendiri. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. Tekan singkat sebuah tombol menjalankan pintasannya. Menahan tombol selama jeda menjalankan alat atau perintah di kolom Tahan sebagai gantinya. Pintasan tahan adalah tombol huruf, angka, atau tanda baca, sendiri atau dengan Shift. +@msg Hold {_1} is already used by {_2} Tahan {_1} sudah digunakan oleh {_2} +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) pintasan tahan adalah tombol yang mengetik karakter, sendiri atau dengan Shift ({shown} memakai Cmd, Ctrl, atau Alt) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} tidak bisa menjadi pintasan tahan: gunakan huruf, angka, atau tombol tanda baca diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 360ec1d5ba..bc0c3854e8 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -9245,3 +9245,13 @@ breakText Glyphs Glifi No objects are selected. Nessun oggetto selezionato. Open a document to mark its fold lines. Apri un documento per segnarne le linee di piega. Remove Fold Line Role Rimuovi tipo di linea + Tap Pressione breve + Clear Hold Cancella pressione prolungata + Hold Shortcuts Scorciatoie a pressione prolungata + Hold Shortcut Delay Ritardo delle scorciatoie a pressione prolungata + How hold shortcuts work Come funzionano le scorciatoie a pressione prolungata + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. Fai clic, poi premi un tasto da tenere premuto per questo (Esc annulla). Tenere premuto il tasto esegue questo; una pressione breve esegue la scorciatoia del tasto stesso. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. Una pressione breve di un tasto esegue la sua scorciatoia. Tenere premuto il tasto per la durata del ritardo esegue invece lo strumento o il comando della sua colonna Tieni premuto. Una scorciatoia a pressione prolungata è un tasto di lettera, cifra o punteggiatura, da solo o con Shift. +@msg Hold {_1} is already used by {_2} La pressione prolungata di {_1} è già usata da {_2} +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) una scorciatoia a pressione prolungata è un tasto che digita un carattere, da solo o con Shift ({shown} ha Cmd, Ctrl o Alt) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} non può essere una scorciatoia a pressione prolungata: usa una lettera, una cifra o un tasto di punteggiatura diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 37089bb835..5262880734 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -9312,3 +9312,13 @@ breakText Glyphs 字形 No objects are selected. オブジェクトが選択されていません。 Open a document to mark its fold lines. ドキュメントを開くと折り線を設定できます。 Remove Fold Line Role 線種を解除 + Tap 短押し + Clear Hold 長押しを消去 + Hold Shortcuts 長押しショートカット + Hold Shortcut Delay 長押しショートカットの遅延 + How hold shortcuts work 長押しショートカットのしくみ + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. クリックしてから、これに使う長押しのキーを押します (Esc でキャンセル)。キーを長押しするとこれを実行し、短く押すとキー自体のショートカットを実行します。 + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. キーを短く押すと、そのショートカットを実行します。遅延の時間だけキーを押し続けると、代わりに長押し列のツールまたはコマンドを実行します。長押しショートカットには、文字、数字、句読点のキーを単独で、または Shift と組み合わせて使用できます。 +@msg Hold {_1} is already used by {_2} 長押し {_1} はすでに {_2} で使用されています +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) 長押しショートカットは、文字を入力するキーを単独で、または Shift と組み合わせたものです ({shown} には Cmd、Ctrl、Alt のいずれかが含まれています) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} は長押しショートカットにできません: 文字、数字、句読点のいずれかのキーを使用してください diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 25fb4f87ed..759bc441c0 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -9885,3 +9885,13 @@ font-script Japanese იაპონური Open a document to mark its fold lines. გახსენით დოკუმენტი მისი მოკეცვის ხაზების მოსანიშნად. Remove Fold Line Role ხაზის ტიპის მოხსნა @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" composer უნდა იყოს "singleLine", "everyLine", "standardSingleLine" ან "standardEveryLine" + Tap მოკლე დაჭერა + Clear Hold ხანგრძლივი დაჭერის გასუფთავება + Hold Shortcuts ხანგრძლივი დაჭერის მალსახმობები + Hold Shortcut Delay ხანგრძლივი დაჭერის დაყოვნება + How hold shortcuts work როგორ მუშაობს ხანგრძლივი დაჭერის მალსახმობები + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. დაწკაპეთ, შემდეგ დააჭირეთ კლავიშს, რომელიც ამისთვის უნდა დაიჭიროთ (Esc აუქმებს). კლავიშის ხანგრძლივი დაჭერა ამას უშვებს; მოკლე დაჭერა კლავიშის საკუთარ მალსახმობს უშვებს. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. კლავიშის მოკლე დაჭერა მის მალსახმობს უშვებს. თუ კლავიშს დაყოვნების ხანგრძლივობით დაიჭერთ, ამის ნაცვლად გაეშვება მისი „დაჭერა“ სვეტის ხელსაწყო ან ბრძანება. ხანგრძლივი დაჭერის მალსახმობი არის ასოს, ციფრის ან სასვენი ნიშნის კლავიში, ცალკე ან Shift კლავიშთან ერთად. +@msg Hold {_1} is already used by {_2} ხანგრძლივი დაჭერა {_1} უკვე გამოიყენება ამისთვის: {_2} +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) ხანგრძლივი დაჭერის მალსახმობი არის კლავიში, რომელიც სიმბოლოს წერს, ცალკე ან Shift კლავიშთან ერთად ({shown} შეიცავს Cmd, Ctrl ან Alt კლავიშს) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} ვერ იქნება ხანგრძლივი დაჭერის მალსახმობი: გამოიყენეთ ასო, ციფრი ან სასვენი ნიშნის კლავიში diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 0787180a1c..f482021c87 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -9208,3 +9208,13 @@ breakText Glyphs 글리프 No objects are selected. 선택한 개체가 없습니다. Open a document to mark its fold lines. 접는 선을 지정하려면 문서를 여세요. Remove Fold Line Role 선 종류 제거 + Tap 짧게 누르기 + Clear Hold 길게 누르기 지우기 + Hold Shortcuts 길게 누르기 단축키 + Hold Shortcut Delay 길게 누르기 단축키 지연 시간 + How hold shortcuts work 길게 누르기 단축키 작동 방식 + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. 클릭한 다음 이 항목에 길게 누를 키를 누르세요 (Esc로 취소). 키를 길게 누르면 이 항목이 실행되고, 짧게 누르면 키 자체의 단축키가 실행됩니다. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. 키를 짧게 누르면 해당 단축키가 실행됩니다. 지연 시간 동안 키를 누르고 있으면 대신 누르고 있기 열의 도구나 명령이 실행됩니다. 길게 누르기 단축키는 문자, 숫자 또는 문장 부호 키이며, 단독으로 또는 Shift와 함께 사용합니다. +@msg Hold {_1} is already used by {_2} 길게 누르기 {_1}은(는) 이미 {_2}에서 사용 중입니다 +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) 길게 누르기 단축키는 문자를 입력하는 키를 단독으로 또는 Shift와 함께 사용해야 합니다 ({shown}에 Cmd, Ctrl 또는 Alt가 있음) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown}은(는) 길게 누르기 단축키가 될 수 없습니다: 문자, 숫자 또는 문장 부호 키를 사용하세요 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index ab30a3639f..4c6a1784f8 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -9646,3 +9646,13 @@ breakText Glyphs Glyphs No objects are selected. Er zijn geen objecten geselecteerd. Open a document to mark its fold lines. Open een document om de vouwlijnen te markeren. Remove Fold Line Role Lijnsoort verwijderen + Tap Kort drukken + Clear Hold Vasthouden wissen + Hold Shortcuts Vasthoudsneltoetsen + Hold Shortcut Delay Vertraging vasthoudsneltoetsen + How hold shortcuts work Zo werken vasthoudsneltoetsen + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. Klik en druk vervolgens een toets in die hiervoor wordt vastgehouden (Esc annuleert). De toets vasthouden voert dit uit; kort drukken voert de eigen sneltoets van de toets uit. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. Kort drukken op een toets voert de sneltoets ervan uit. De toets vasthouden gedurende de vertraging voert in plaats daarvan het gereedschap of de opdracht in de kolom Houd uit. Een vasthoudsneltoets is een letter-, cijfer- of leestekentoets, alleen of met Shift. +@msg Hold {_1} is already used by {_2} Vasthouden {_1} wordt al gebruikt door {_2} +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) een vasthoudsneltoets is een toets die een teken typt, alleen of met Shift ({shown} bevat Cmd, Ctrl of Alt) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} kan geen vasthoudsneltoets zijn: gebruik een letter, een cijfer of een leestekentoets diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 085935a9bd..598e2cc6eb 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -9466,3 +9466,13 @@ breakText Glyphs Glify No objects are selected. Nie zaznaczono żadnych obiektów. Open a document to mark its fold lines. Otwórz dokument, aby oznaczyć jego linie zgięcia. Remove Fold Line Role Usuń rodzaj linii + Tap Krótkie naciśnięcie + Clear Hold Wyczyść przytrzymanie + Hold Shortcuts Skróty przytrzymania + Hold Shortcut Delay Opóźnienie skrótów przytrzymania + How hold shortcuts work Jak działają skróty przytrzymania + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. Kliknij, a następnie naciśnij klawisz, który ma być przytrzymywany dla tego elementu (Esc anuluje). Przytrzymanie klawisza uruchamia ten element; krótkie naciśnięcie uruchamia własny skrót klawisza. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. Krótkie naciśnięcie klawisza uruchamia jego skrót. Przytrzymanie klawisza przez czas opóźnienia uruchamia zamiast tego narzędzie lub polecenie z jego kolumny Przytrzymaj. Skrót przytrzymania to klawisz litery, cyfry lub znaku interpunkcyjnego, sam lub z Shift. +@msg Hold {_1} is already used by {_2} Przytrzymanie {_1} jest już używane przez {_2} +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) skrót przytrzymania to klawisz wpisujący znak, sam lub z Shift ({shown} zawiera Cmd, Ctrl lub Alt) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} nie może być skrótem przytrzymania: użyj litery, cyfry lub klawisza interpunkcyjnego diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 0289161fe4..d2bb22f8be 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -9684,3 +9684,13 @@ swatch Yellow Green Verde-amarelado No objects are selected. Nenhum objeto selecionado. Open a document to mark its fold lines. Abra um documento para marcar suas linhas de dobra. Remove Fold Line Role Remover Tipo de Linha + Tap Toque Rápido + Clear Hold Limpar Pressionamento Longo + Hold Shortcuts Atalhos de Pressionamento Longo + Hold Shortcut Delay Atraso dos Atalhos de Pressionamento Longo + How hold shortcuts work Como funcionam os atalhos de pressionamento longo + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. Clique e depois pressione uma tecla para manter pressionada para isto (Esc cancela). Manter a tecla pressionada executa isto; um toque rápido executa o atalho da própria tecla. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. Um toque rápido em uma tecla executa o atalho dela. Manter a tecla pressionada pelo tempo do atraso executa, em vez disso, a ferramenta ou o comando da coluna Manter pressionado. Um atalho de pressionamento longo é uma tecla de letra, número ou pontuação, sozinha ou com Shift. +@msg Hold {_1} is already used by {_2} O pressionamento longo de {_1} já é usado por {_2} +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) um atalho de pressionamento longo é uma tecla que digita um caractere, sozinha ou com Shift ({shown} tem Cmd, Ctrl ou Alt) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} não pode ser um atalho de pressionamento longo: use uma letra, um número ou uma tecla de pontuação diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index e45ac9423a..bd4c98a94a 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -9709,3 +9709,13 @@ shape Open Открытый Remove Fold Line Role Убрать тип линии @msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} пикселей — слишком большой размер для PSD (не более {MAX_SIDE} пикселей по стороне): уменьшите разрешение @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" composer должен быть "singleLine", "everyLine", "standardSingleLine" или "standardEveryLine" + Tap Короткое нажатие + Clear Hold Очистить удержание + Hold Shortcuts Клавиши удержания + Hold Shortcut Delay Задержка клавиш удержания + How hold shortcuts work Как работают клавиши удержания + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. Щелкните, затем нажмите клавишу, которую нужно удерживать для этого (Esc отменяет). Удержание клавиши запускает это; короткое нажатие запускает собственное сочетание клавиши. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. Короткое нажатие клавиши запускает ее сочетание. Удержание клавиши в течение задержки запускает вместо этого инструмент или команду из ее столбца «Удерживать». Клавиша удержания — это клавиша буквы, цифры или знака препинания, отдельно или с Shift. +@msg Hold {_1} is already used by {_2} Удержание {_1} уже используется для {_2} +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) клавиша удержания — это клавиша, которая вводит символ, отдельно или с Shift ({shown} содержит Cmd, Ctrl или Alt) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} не может быть клавишей удержания: используйте букву, цифру или клавишу знака препинания diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 95e7c34b47..5b599e4df9 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -9283,3 +9283,13 @@ digits Hindi Hindi Open a document to mark its fold lines. Öppna ett dokument för att markera dess falslinjer. Remove Fold Line Role Ta bort linjetyp @msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} pixlar är för stort för PSD (högst {MAX_SIDE} pixlar per sida): sänk upplösningen + Tap Kort tryck + Clear Hold Rensa håll + Hold Shortcuts Hållkortkommandon + Hold Shortcut Delay Fördröjning för hållkortkommandon + How hold shortcuts work Så fungerar hållkortkommandon + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. Klicka och tryck sedan på en tangent som ska hållas ned för detta (Esc avbryter). Att hålla ned tangenten kör detta; ett kort tryck kör tangentens eget kortkommando. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. Ett kort tryck på en tangent kör dess kortkommando. Att hålla ned tangenten under fördröjningen kör i stället verktyget eller kommandot i dess Håll-kolumn. Ett hållkortkommando är en bokstavs-, siffer- eller skiljeteckentangent, ensam eller med Shift. +@msg Hold {_1} is already used by {_2} Håll {_1} används redan av {_2} +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) ett hållkortkommando är en tangent som skriver ett tecken, ensam eller med Shift ({shown} har Cmd, Ctrl eller Alt) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} kan inte vara ett hållkortkommando: använd en bokstav, en siffra eller en skiljeteckentangent diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index d8249b1c79..ef10a57c7d 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -9567,3 +9567,13 @@ breakText Glyphs Glifler No objects are selected. Hiçbir nesne seçili değil. Open a document to mark its fold lines. Katlama çizgilerini işaretlemek için bir belgeyi açın. Remove Fold Line Role Çizgi Türünü Kaldır + Tap Kısa Basma + Clear Hold Basılı Tutmayı Temizle + Hold Shortcuts Basılı Tutma Kısayolları + Hold Shortcut Delay Basılı Tutma Kısayolu Gecikmesi + How hold shortcuts work Basılı tutma kısayolları nasıl çalışır + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. Tıklayın, ardından bunun için basılı tutulacak tuşa basın (Esc iptal edilir). Tuşu basılı tutmak bunu çalıştırır; kısa basmak tuşun kendi kısayolunu çalıştırır. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. Bir tuşa kısa basmak onun kısayolunu çalıştırır. Tuşu gecikme süresi boyunca basılı tutmak bunun yerine Basılı tutun sütunundaki aracı veya komutu çalıştırır. Basılı tutma kısayolu, tek başına veya Shift ile bir harf, rakam ya da noktalama tuşudur. +@msg Hold {_1} is already used by {_2} Basılı tutma {_1} zaten {_2} tarafından kullanılıyor +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) basılı tutma kısayolu, tek başına veya Shift ile bir karakter yazan tuştur ({shown} Cmd, Ctrl veya Alt içeriyor) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} basılı tutma kısayolu olamaz: bir harf, rakam veya noktalama tuşu kullanın diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 8ebb97a5be..e5ab45e496 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -9220,3 +9220,13 @@ breakText Glyphs Гліфи No objects are selected. Об’єкти не виділено. Open a document to mark its fold lines. Відкрийте документ, щоб позначити його лінії згину. Remove Fold Line Role Прибрати тип лінії + Tap Коротке натискання + Clear Hold Очистити утримання + Hold Shortcuts Клавіші утримання + Hold Shortcut Delay Затримка клавіш утримання + How hold shortcuts work Як працюють клавіші утримання + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. Клацніть, потім натисніть клавішу, яку слід утримувати для цього (Esc скасовує). Утримання клавіші запускає це; коротке натискання запускає власне сполучення клавіші. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. Коротке натискання клавіші запускає її сполучення. Утримання клавіші протягом затримки запускає натомість інструмент або команду з її стовпця «Утримувати». Клавіша утримання — це клавіша літери, цифри або розділового знака, окремо або з Shift. +@msg Hold {_1} is already used by {_2} Утримання {_1} вже використовується для {_2} +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) клавіша утримання — це клавіша, що вводить символ, окремо або з Shift ({shown} містить Cmd, Ctrl або Alt) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} не може бути клавішею утримання: використайте літеру, цифру або клавішу розділового знака diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index a9a9cb140a..23ef3d3845 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -7424,3 +7424,13 @@ breakText Glyphs Glyph @msg {width} × {height} pixels is too large for Targa (at most 65535 pixels a side): lower the resolution {width} × {height} điểm ảnh quá lớn cho Targa (tối đa 65535 điểm ảnh mỗi cạnh): hãy giảm độ phân giải @msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} điểm ảnh quá lớn cho PSD (tối đa {MAX_SIDE} điểm ảnh mỗi cạnh): hãy giảm độ phân giải @msg composer must be "singleLine", "everyLine", "standardSingleLine" or "standardEveryLine" composer phải là "singleLine", "everyLine", "standardSingleLine" hoặc "standardEveryLine" + Tap Nhấn nhanh + Clear Hold Xóa nhấn giữ + Hold Shortcuts Phím tắt nhấn giữ + Hold Shortcut Delay Độ trễ phím tắt nhấn giữ + How hold shortcuts work Cách phím tắt nhấn giữ hoạt động + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. Nhấp, rồi nhấn phím cần giữ cho mục này (Esc để hủy). Giữ phím sẽ chạy mục này; nhấn nhanh sẽ chạy phím tắt riêng của phím đó. + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. Nhấn nhanh một phím sẽ chạy phím tắt của phím đó. Giữ phím trong khoảng độ trễ sẽ chạy công cụ hoặc lệnh trong cột Giữ của phím thay vào đó. Phím tắt nhấn giữ là một phím chữ cái, chữ số hoặc dấu câu, dùng riêng hoặc cùng Shift. +@msg Hold {_1} is already used by {_2} Nhấn giữ {_1} đã được {_2} sử dụng +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) phím tắt nhấn giữ là một phím gõ ra ký tự, dùng riêng hoặc cùng Shift ({shown} có Cmd, Ctrl hoặc Alt) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} không thể là phím tắt nhấn giữ: hãy dùng chữ cái, chữ số hoặc phím dấu câu diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index f3a87e6b84..76ff60f06d 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -9452,3 +9452,13 @@ breakText Glyphs 字形 Open a document to mark its fold lines. 打开文档以标记其折线。 Remove Fold Line Role 移除线条类型 @msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} 像素对 PSD 而言过大 (每边最多 {MAX_SIDE} 像素):请降低分辨率 + Tap 短按 + Clear Hold 清除按住 + Hold Shortcuts 按住快捷键 + Hold Shortcut Delay 按住快捷键延迟 + How hold shortcuts work 按住快捷键的工作方式 + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. 单击后按下要为此按住的键 (Esc 取消)。按住该键会运行此项;短按会运行该键自己的快捷键。 + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. 短按一个键会运行它的快捷键。按住该键达到延迟时间,则改为运行其“按住”列中的工具或命令。按住快捷键是字母、数字或标点键,可单独使用或与 Shift 组合。 +@msg Hold {_1} is already used by {_2} 按住 {_1} 已被 {_2} 使用 +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) 按住快捷键是可输入字符的键,单独使用或与 Shift 组合 ({shown} 含有 Cmd、Ctrl 或 Alt) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} 不能作为按住快捷键:请使用字母、数字或标点键 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 52715f8360..e7a8224e13 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -9262,3 +9262,13 @@ breakText Glyphs 字符 Open a document to mark its fold lines. 開啟文件以標記其摺線。 Remove Fold Line Role 移除線條類型 @msg {what} would print on more than {MAX_TILES} tiles: scale it down {what} 會列印在超過 {MAX_TILES} 個拼貼上:請縮小 + Tap 短按 + Clear Hold 清除按住 + Hold Shortcuts 按住快速鍵 + Hold Shortcut Delay 按住快速鍵延遲 + How hold shortcuts work 按住快速鍵的運作方式 + Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut. 按一下後按下要為此按住的按鍵 (Esc 取消)。按住該按鍵會執行此項;短按會執行該按鍵本身的快速鍵。 + A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift. 短按按鍵會執行它的快速鍵。按住按鍵達延遲時間,則改為執行其「按住」欄中的工具或命令。按住快速鍵是字母、數字或標點符號按鍵,可單獨使用或搭配 Shift。 +@msg Hold {_1} is already used by {_2} 按住 {_1} 已被 {_2} 使用 +@msg a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt) 按住快速鍵是可輸入字元的按鍵,可單獨使用或搭配 Shift ({shown} 含有 Cmd、Ctrl 或 Alt) +@msg {shown} can't be a hold shortcut: use a letter, a digit or a punctuation key {shown} 不能作為按住快速鍵:請使用字母、數字或標點符號按鍵 diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 3f89789d5d..7f13d34da3 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -368,6 +368,9 @@ pub struct VectorcraftApp { /// The single-key tool shortcuts held down, the last held last, and the tool each goes back to /// when it is let go ([`shortcuts::HeldTool`]). pub(crate) held_tool: Vec, + /// A key with a hold shortcut that waits for its release, and the keys whose repeats are held + /// back until they are let go ([`shortcuts::HoldKeys`]). + pub(crate) hold_keys: shortcuts::HoldKeys, /// A synthetic batch is in the host's raw input and no settled UI pass has taken it yet. synthetic_injected: bool, /// The exact events of [`Self::synthetic_injected`], to remove them if the state they belong diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index 4c286f1da9..dbe67c5916 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -174,8 +174,13 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "Cmd+I", "{} open the Check Spelling dialog to walk through unrecognized words with suggestions, ignore, change and dictionary options", ), - ("shortcuts.set", "Set Keyboard Shortcut", "", "{id: command id or tool:, shortcut: \"Cmd+Shift+K\" | \"\" (none) | null (default), force?}"), - ("shortcuts.list", "List Keyboard Shortcuts", "", "{query?} → [{id, label, group, shortcut, default, overridden}]"), + ( + "shortcuts.set", + "Set Keyboard Shortcut", + "", + "{id: command id or tool:, shortcut?: \"Cmd+Shift+K\" | \"\" (none) | null (default), hold?: a character key alone or with Shift (\"X\", \"Shift+X\", \".\") | \"\" | null (none), force?} → {id, shortcut, hold, removedFrom}; `hold` alone leaves the shortcut as it is; a hold shortcut acts while the holdShortcuts preference is on", + ), + ("shortcuts.list", "List Keyboard Shortcuts", "", "{query?} → [{id, label, group, shortcut, hold, default, overridden}]"), ("shortcuts.conflicts", "Keyboard Shortcut Conflicts", "", "{} → [{shortcut, ids}]"), ("shortcuts.reset", "Reset Keyboard Shortcuts", "", "{}"), ( @@ -189,7 +194,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "shortcuts.exportText", "Export Keyboard Shortcuts as Text…", "", - "{path?} save the current set's tools and menu commands with their shortcuts as a UTF-8 text file (Keyboard Shortcuts › Export Text…): the set's name, then a Tools and a Menu Commands section in the dialog's order, one `nameshortcut` line per row, empty after the tab when it has none; without `path`, pick a file", + "{path?} save the current set's tools and menu commands with their shortcuts as a UTF-8 text file (Keyboard Shortcuts › Export Text…): the set's name, then a Tools and a Menu Commands section in the dialog's order, one `nameshortcut` line per row, empty after the tab when it has none, and while the holdShortcuts preference is on a third `Hold ` column on a row with a hold shortcut; without `path`, pick a file", ), ("shortcuts.import", "Import Keyboard Shortcuts…", "", "{path? | data?}"), ( diff --git a/crates/ui-egui/src/prefs_dialog.rs b/crates/ui-egui/src/prefs_dialog.rs index f9939177de..c01a31d754 100644 --- a/crates/ui-egui/src/prefs_dialog.rs +++ b/crates/ui-egui/src/prefs_dialog.rs @@ -580,6 +580,18 @@ fn category_fields(ui: &mut egui::Ui, app: &mut VectorcraftApp, d: &mut Dialog, } } PrefKind::Bool => bool_row(ui, d, sp.key, sp.label), + // General › Hold Shortcut Delay acts only while Hold Shortcuts is on: dimmed while it + // is off, as in Edit › Keyboard Shortcuts, which shows it only then. + PrefKind::Num { min, max, unit } if sp.key == "keyHoldDelay" => { + ui.add_enabled_ui(d.bool("holdShortcuts"), |ui| { + labeled(ui, sp.label, |ui, _| { + let x = v.as_f64().unwrap_or(min); + if let Some(x) = widgets::range_field(ui, sp.key, x, min..=max, &format!(" {unit}"), 3, 110.0) { + d.fields.insert(sp.key.into(), json!(x)); + } + }); + }); + } PrefKind::Num { min, max, unit } => { labeled(ui, sp.label, |ui, label_id| { let mut x = v.as_f64().unwrap_or(min); diff --git a/crates/ui-egui/src/prefs_dialog/tests.rs b/crates/ui-egui/src/prefs_dialog/tests.rs index 5c9356edd9..84b9abd4af 100644 --- a/crates/ui-egui/src/prefs_dialog/tests.rs +++ b/crates/ui-egui/src/prefs_dialog/tests.rs @@ -1093,6 +1093,45 @@ fn scroll_sideways_with_cmd_wheel_dims_with_zoom_with_mouse_wheel() { } } +/// General › Hold Shortcut Delay: its field is dimmed while Hold Shortcuts is unchecked in the +/// dialog, and a click on it then does not give it the keyboard. +#[test] +fn hold_shortcut_delay_dims_without_hold_shortcuts() { + fn text(s: &egui::Shape, f: &dyn Fn(&str) -> bool) -> Option { + match s { + egui::Shape::Text(t) if f(t.galley.text()) => Some(t.visual_bounding_rect()), + egui::Shape::Vec(v) => v.iter().find_map(|s| text(s, f)), + _ => None, + } + } + for on in [true, false] { + let ctx = egui::Context::default(); + crate::theme::install_fonts(&ctx); + let mut a = app(); + let mut d = Dialog::new("preferences", json!({"holdShortcuts": on, "keyHoldDelay": 0.35})); + let mut frame = |d: &mut Dialog, events: Vec| { + let raw = egui::RawInput { + screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(600.0, 2400.0))), + events, + ..Default::default() + }; + let mut out = ctx.run_ui(raw, |ui| category_fields(ui, &mut a, d, "General")); + out.textures_delta.clear(); + let label = out.shapes.iter().find_map(|c| text(&c.shape, &|t| t.starts_with("Hold Shortcut Delay"))); + let field = out.shapes.iter().find_map(|c| text(&c.shape, &|t| t.starts_with("0.35"))); + (label, field) + }; + let (label, field) = frame(&mut d, vec![]); + assert!(label.is_some(), "no label (on {on})"); + let at = field.unwrap_or_else(|| panic!("no field (on {on})")); + let press = + |pressed| egui::Event::PointerButton { pos: at.center(), button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; + frame(&mut d, vec![egui::Event::PointerMoved(at.center()), press(true)]); + frame(&mut d, vec![press(false)]); + assert_eq!(ctx.memory(|m| m.focused().is_some()), on, "a click gives the field the keyboard only while Hold Shortcuts is on ({on})"); + } +} + /// Type › Show samples on white: its checkbox is dimmed while Enable in-menu font previews is /// unchecked in the dialog, and a click on it then leaves the setting as it was. #[test] diff --git a/crates/ui-egui/src/shortcut_editor.rs b/crates/ui-egui/src/shortcut_editor.rs index 88a97206c7..da0448162c 100644 --- a/crates/ui-egui/src/shortcut_editor.rs +++ b/crates/ui-egui/src/shortcut_editor.rs @@ -1141,6 +1141,89 @@ pub fn reset_one(overrides: &mut Overrides, key: &str) { crate::keymap::remove_override(overrides, key); } +/// Hold shortcuts: entry key → chord text ([`UiState::shortcut_holds`]). +pub type Holds = BTreeMap; + +/// The chord of hold shortcut text `text`, or why it can't be one. A hold shortcut is a key that +/// types a character, alone or with Shift. Space and the backtick key are refused: the canvas reads +/// them while they are held. +pub fn hold_chord(text: &str) -> Result { + let chord = vc_chord(text).ok_or_else(|| format!("can't parse shortcut `{text}`"))?; + let shown = menus::pretty_shortcut(&vc_format(&chord)); + if chord.mods.cmd || chord.mods.ctrl || chord.mods.alt { + return Err(format!("a hold shortcut is a key that types a character, alone or with Shift ({shown} has Cmd, Ctrl or Alt)")); + } + if chord.key == craft_keymap::Key::Backtick || !crate::shortcuts::types_text(chord.key) { + return Err(format!("{shown} can't be a hold shortcut: use a letter, a digit or a punctuation key")); + } + Ok(chord) +} + +/// The hold shortcut of `key` in `holds`, in VectorCraft's chord spelling, when it is usable. +pub fn hold_of(holds: &Holds, key: &str) -> Option { + holds.get(key).and_then(|t| hold_chord(t).ok()).map(|c| vc_format(&c)) +} + +/// The entry whose usable hold shortcut is `chord`: the first in `holds`' order when several are. +/// An entry no longer listed (a removed plug-in's) keeps its text but does not hold. +pub(crate) fn hold_for<'a>(holds: &'a Holds, chord: &craft_keymap::Chord) -> Option<&'a str> { + holds.iter().find(|(k, t)| hold_chord(t).is_ok_and(|c| c == *chord) && entry(k).is_some()).map(|(k, _)| k.as_str()) +} + +/// Sets (`Some`) or removes (`None` or `""`) the hold shortcut of `key`. Another entry that holds +/// the same key loses it when `force`; otherwise that is an error. Returns the entries that lost +/// it. Nothing changes on an error. +pub fn assign_hold(holds: &mut Holds, key: &str, text: Option<&str>, force: bool) -> Result, String> { + if entry(key).is_none() { + return Err(format!("unknown tool or command `{key}`")); + } + let Some(text) = text.filter(|t| !t.is_empty()) else { + holds.remove(key); + return Ok(vec![]); + }; + let chord = hold_chord(text)?; + let taken: Vec = holds.iter().filter(|(k, t)| *k != key && vc_chord(t) == Some(chord)).map(|(k, _)| k.clone()).collect(); + if !taken.is_empty() && !force { + let names: Vec = taken.iter().map(|k| entry(k).map_or(k.clone(), |e| english_name(&e))).collect(); + return Err(format!("Hold {} is already used by {}", menus::pretty_shortcut(&vc_format(&chord)), names.join(", "))); + } + for k in &taken { + holds.remove(k); + } + holds.insert(key.to_string(), vc_format(&chord)); + Ok(taken) +} + +/// Hold shortcuts used by more than one entry: (chord text, entry keys). +pub fn hold_conflicts(holds: &Holds) -> Vec<(String, Vec)> { + let mut by: BTreeMap> = BTreeMap::new(); + for (k, t) in holds { + if let Ok(c) = hold_chord(t) { + by.entry(vc_format(&c)).or_default().push(k.clone()); + } + } + by.into_iter().filter(|(_, keys)| keys.len() > 1).collect() +} + +/// The hold shortcuts of an exported set's `holds` member: none when it is missing. Every value +/// must be a usable hold shortcut; otherwise the error names the first entry that is not. +pub fn import_holds(v: &Value) -> Result { + let Some(h) = v.get("holds") else { return Ok(Holds::new()) }; + let h = h.as_object().ok_or("`holds` must be an object")?; + let mut out = Holds::new(); + for (k, v) in h { + let s = v.as_str().ok_or_else(|| format!("hold shortcut for `{k}` must be a string"))?; + let c = hold_chord(s).map_err(|e| format!("hold shortcut for `{k}`: {e}"))?; + out.insert(k.clone(), vc_format(&c)); + } + Ok(out) +} + +/// The hold shortcuts of the Keyboard Shortcuts dialog's working set. +fn dialog_holds(d: &Dialog) -> Holds { + d.fields.get("holds").and_then(|v| serde_json::from_value(v.clone()).ok()).unwrap_or_default() +} + /// Text shown for all active chords in a dialog row, with the backtick key shown as `typed` /// ([`backtick_text`]). fn dialog_shortcuts_with(km: &Keymap, key: &str, typed: Option<&str>) -> Option { @@ -1161,7 +1244,17 @@ pub fn preset(name: &str) -> Option { /// Export format: `{"format": "vectorcraft-shortcuts", "set": name, "overrides": {...}}`. pub fn export_json(set: &str, overrides: &Overrides) -> Value { - json!({"format": "vectorcraft-shortcuts", "version": 1, "set": set, "overrides": stored::to_value(overrides)}) + export_json_with(set, overrides, &Holds::new()) +} + +/// [`export_json`] with the set's hold shortcuts, written as `holds` when there are any. The +/// version stays 1: earlier versions read `overrides` only, so they import the file without them. +pub fn export_json_with(set: &str, overrides: &Overrides, holds: &Holds) -> Value { + let mut v = json!({"format": "vectorcraft-shortcuts", "version": 1, "set": set, "overrides": stored::to_value(overrides)}); + if !holds.is_empty() { + v["holds"] = json!(holds); + } + v } pub fn import_json(v: &Value) -> Result<(String, Overrides), String> { @@ -1181,6 +1274,11 @@ pub fn import_json(v: &Value) -> Result<(String, Overrides), String> { /// row per line with the name and the shortcuts as the dialog shows them, separated by a tab. A /// row with no shortcut ends after the tab. pub fn export_text(set: &str, overrides: &Overrides) -> String { + export_text_with(set, overrides, &Holds::new()) +} + +/// [`export_text`] with the set's hold shortcuts: a row with one gets a third column, `Hold X`. +pub fn export_text_with(set: &str, overrides: &Overrides, holds: &Holds) -> String { let snapshot = snapshot(); let km = crate::keymap::keymap_in(&snapshot, overrides); let backtick = backtick_text(); @@ -1191,7 +1289,10 @@ pub fn export_text(set: &str, overrides: &Overrides) -> String { for e in snapshot.entries.iter().filter(|e| e.is_tool == tools && listed(km.overrides(), e)) { let name = shown_name(e); let sc = dialog_shortcuts_with(&km, &e.key, backtick.as_deref()).unwrap_or_default(); - out += &format!("{name}\t{sc}\n"); + match hold_of(holds, &e.key) { + Some(h) => out += &format!("{name}\t{sc}\t{} {}\n", tl!("Hold"), menus::pretty_shortcut(&h)), + None => out += &format!("{name}\t{sc}\n"), + } } } out @@ -1203,10 +1304,35 @@ pub fn open(app: &mut VectorcraftApp) { let ov = stored::to_value(&app.ui.shortcut_overrides); app.ui.dialog = Some(Dialog::new( "shortcuts", - json!({"tab": "tools", "query": "", "set": app.ui.shortcut_set, "overrides": ov, "__recording": "", "__selected": "", "__message": "", "__conflict": ""}), + json!({ + "tab": "tools", + "query": "", + "set": app.ui.shortcut_set, + "overrides": ov, + "holds": app.ui.shortcut_holds, + "holdShortcuts": app.session.prefs.hold_shortcuts, + "keyHoldDelay": app.session.prefs.key_hold_delay(), + "__holdInfo": false, + "__recording": "", + "__recordingHold": false, + "__selected": "", + "__message": "", + "__conflict": "" + }), )); } +/// Hold Shortcuts in the Keyboard Shortcuts dialog's working copy. +fn dialog_holds_on(d: &Dialog) -> bool { + d.bool("holdShortcuts") +} + +/// The Hold Shortcut Delay in the Keyboard Shortcuts dialog's working copy, in its range. +fn dialog_hold_delay(d: &Dialog) -> f64 { + let (min, max) = vectorcraft_engine::KEY_HOLD_DELAY_RANGE; + d.fields.get("keyHoldDelay").and_then(Value::as_f64).filter(|x| x.is_finite()).map_or(vectorcraft_engine::KEY_HOLD_DELAY, |x| x.clamp(min, max)) +} + fn dialog_overrides(d: &Dialog) -> Overrides { d.fields.get("overrides").map(|v| stored::from_value(v.clone())).unwrap_or_default() } @@ -1214,7 +1340,13 @@ fn dialog_overrides(d: &Dialog) -> Overrides { /// OK: commit the working set. pub fn confirm(app: &mut VectorcraftApp) -> Result { let Some(d) = app.ui.dialog.clone() else { return Err("no dialog open".into()) }; + let (on, delay) = (dialog_holds_on(&d), dialog_hold_delay(&d)); + let prefs = &app.session.prefs; + if d.kind == "shortcuts" && (on != prefs.hold_shortcuts || delay != prefs.key_hold_delay()) { + app.run("prefs.set", json!({"values": {"holdShortcuts": on, "keyHoldDelay": delay}})).map_err(|e| e.to_string())?; + } app.ui.shortcut_overrides = dialog_overrides(&d); + app.ui.shortcut_holds = dialog_holds(&d); app.ui.shortcut_set = d.str("set"); app.ui.dialog = None; sync(&app.ui); @@ -1244,18 +1376,45 @@ pub fn run_command(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option (key.unwrap_or_default(), shortcut, force.unwrap_or(false)), (Err(e), _, _) | (_, Err(e), _) | (_, _, Err(e)) => return Some(Err(e)), }; + let hold = match s("hold") { + Ok(hold) => hold, + Err(e) => return Some(Err(e)), + }; + // Without `hold`, a missing `shortcut` removes the shortcut, as it always has; with + // `hold` alone, the shortcut is left as it is. Both are checked before either is kept. + let has_hold = p.get("hold").is_some(); + let has_shortcut = p.get("shortcut").is_some() || !has_hold; let mut ov = app.ui.shortcut_overrides.clone(); - let r = if p.get("shortcut").is_some_and(Value::is_null) { + let mut holds = app.ui.shortcut_holds.clone(); + let r = if !has_shortcut { + Ok(vec![]) + } else if p.get("shortcut").is_some_and(Value::is_null) { reset_one(&mut ov, &key); Ok(vec![]) } else { assign(&mut ov, &key, shortcut.as_deref(), force) }; + let r = r.and_then(|mut removed| { + if has_hold { + for k in assign_hold(&mut holds, &key, hold.as_deref(), force)? { + if !removed.contains(&k) { + removed.push(k); + } + } + } + Ok(removed) + }); r.map(|removed| { app.ui.shortcut_overrides = ov; + app.ui.shortcut_holds = holds; app.ui.shortcut_set = CUSTOM.into(); sync(&app.ui); - json!({"id": key, "shortcut": effective_in(&app.ui.shortcut_overrides, &key), "removedFrom": removed}) + json!({ + "id": key, + "shortcut": effective_in(&app.ui.shortcut_overrides, &key), + "hold": hold_of(&app.ui.shortcut_holds, &key), + "removedFrom": removed + }) }) } "shortcuts.list" => { @@ -1272,15 +1431,19 @@ pub fn run_command(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option { - Ok(json!(all_conflicts(&app.ui.shortcut_overrides).into_iter().map(|(c, k)| json!({"shortcut": c, "ids": k})).collect::>())) + let holds = hold_conflicts(&app.ui.shortcut_holds).into_iter().map(|(c, k)| (format!("Hold {c}"), k)); + Ok(json!( + all_conflicts(&app.ui.shortcut_overrides).into_iter().chain(holds).map(|(c, k)| json!({"shortcut": c, "ids": k})).collect::>() + )) } "shortcuts.reset" => { app.ui.shortcut_overrides.clear(); + app.ui.shortcut_holds.clear(); app.ui.shortcut_set = PRESETS[0].into(); sync(&app.ui); Ok(Value::Null) @@ -1288,6 +1451,8 @@ pub fn run_command(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option match s("name").map(|n| n.as_deref().map(set_name).and_then(|n| preset(n).map(|p| (n.to_string(), p)))) { Ok(Some((n, p))) => { app.ui.shortcut_overrides = p; + // The presets have no hold shortcuts. + app.ui.shortcut_holds.clear(); app.ui.shortcut_set = n; sync(&app.ui); Ok(Value::Null) @@ -1300,7 +1465,7 @@ pub fn run_command(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option path, Err(e) => return Some(Err(e)), }; - let v = export_json(&app.ui.shortcut_set, &app.ui.shortcut_overrides); + let v = export_json_with(&app.ui.shortcut_set, &app.ui.shortcut_overrides, &app.ui.shortcut_holds); let bytes = serde_json::to_vec_pretty(&v).unwrap_or_default(); let pick = crate::FilePick { filters: vec![crate::FilePick::filter("Shortcut sets", &["json"])], @@ -1329,7 +1494,9 @@ pub fn run_command(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option Option Err("no file reader".into()), } }; - data.and_then(|v| import_json(&v)).map(|(set, ov)| { + data.and_then(|v| Ok((import_json(&v)?, import_holds(&v)?))).map(|((set, ov), holds)| { let n = ov.len(); app.ui.shortcut_overrides = ov; + app.ui.shortcut_holds = holds; app.ui.shortcut_set = set; sync(&app.ui); if let Some(d) = app.ui.dialog.as_mut().filter(|d| d.kind == "shortcuts") { d.fields.insert("overrides".into(), stored::to_value(&app.ui.shortcut_overrides)); + d.fields.insert("holds".into(), json!(app.ui.shortcut_holds)); d.fields.insert("set".into(), json!(app.ui.shortcut_set)); } json!({"overrides": n}) @@ -1466,7 +1635,10 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) { let mut cancel = false; drop_hidden(&mut d, km.overrides()); let saved = dialog_overrides(&d); + let mut holds = dialog_holds(&d); let recording = d.str("__recording"); + // Which column records: the Hold column, or the Shortcut column. + let recording_hold = !recording.is_empty() && d.bool("__recordingHold"); // Record a chord (before widgets see the keys). Modifiers held down are part of the next key's // chord, not a chord of their own. if !recording.is_empty() { @@ -1481,7 +1653,11 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) { if key == Key::Escape { d.fields.insert("__recording".into(), json!("")); } else if let Some(chord) = chord_from_event(key, m) { - record(&mut d, km.to_mut(), &recording, &chord); + if recording_hold { + record_hold(&mut d, &mut holds, &recording, &chord); + } else { + record(&mut d, km.to_mut(), &recording, &chord); + } } } } @@ -1503,6 +1679,8 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) { && let Some(p) = preset(name) { km.to_mut().set_overrides(p); + // The presets have no hold shortcuts. + holds.clear(); d.fields.insert("set".into(), json!(name)); d.fields.insert("__message".into(), json!("")); } @@ -1518,10 +1696,13 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) { } if ui.button(tl!("Reset to Defaults")).clicked() { km.to_mut().reset_all(); + holds.clear(); d.fields.insert("set".into(), json!(PRESETS[0])); d.fields.insert("__message".into(), json!(tl!("All shortcuts reset to defaults."))); } }); + ui.add_space(6.0); + hold_row(ui, &t, &mut d); ui.add_space(8.0); // Tabs + search. ui.horizontal(|ui| { @@ -1544,14 +1725,25 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) { let q = d.str("query").to_lowercase(); let selected = d.str("__selected"); let rec = d.str("__recording"); + let rec_hold = d.bool("__recordingHold"); + let holds_on = dialog_holds_on(&d); let scroll_to = d.fields.remove("__scrollTo").and_then(|v| v.as_str().map(str::to_string)); egui::Frame::NONE.fill(t.input).stroke(egui::Stroke::new(1.0, t.input_border)).inner_margin(egui::Margin::same(4)).show(ui, |ui| { ui.horizontal(|ui| { - ui.allocate_ui_with_layout(egui::vec2(360.0, 16.0), egui::Layout::left_to_right(egui::Align::Center), |ui| { - ui.set_min_width(360.0); + let name_width = if holds_on { 340.0 } else { 360.0 }; + ui.allocate_ui_with_layout(egui::vec2(name_width, 16.0), egui::Layout::left_to_right(egui::Align::Center), |ui| { + ui.set_min_width(name_width); ui.label(egui::RichText::new(if tools { tl!("Tool") } else { tl!("Command") }).color(t.text_dim).size(11.0)); }); - ui.label(egui::RichText::new(tl!("Shortcut")).color(t.text_dim).size(11.0)); + if holds_on { + ui.allocate_ui_with_layout(egui::vec2(150.0, 16.0), egui::Layout::left_to_right(egui::Align::Center), |ui| { + ui.set_min_width(150.0); + ui.label(egui::RichText::new(tl!("Shortcut")).color(t.text_dim).size(11.0)); + }); + ui.label(egui::RichText::new(tl!("Hold")).color(t.text_dim).size(11.0)); + } else { + ui.label(egui::RichText::new(tl!("Shortcut")).color(t.text_dim).size(11.0)); + } }); egui::ScrollArea::vertical().max_height(360.0).auto_shrink([false, false]).show(ui, |ui| { for (i, e) in view.entries.iter().enumerate().filter(|(_, e)| e.is_tool == tools && listed(km.overrides(), e)) { @@ -1564,23 +1756,44 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) { } let row = ui.horizontal(|ui| { let name = shown_name(e); + let name_width = if holds_on { 340.0 } else { 360.0 }; let r = ui - .allocate_ui_with_layout(egui::vec2(360.0, 20.0), egui::Layout::left_to_right(egui::Align::Center), |ui| { - ui.set_min_width(360.0); + .allocate_ui_with_layout(egui::vec2(name_width, 20.0), egui::Layout::left_to_right(egui::Align::Center), |ui| { + ui.set_min_width(name_width); ui.add(egui::Button::selectable(selected == e.key, egui::RichText::new(name).color(t.text)).truncate()) }) .inner; if r.clicked() { d.fields.insert("__selected".into(), json!(e.key)); } - let label = if rec == e.key { tl!("Press keys…").to_string() } else { sc.unwrap_or_else(|| "—".into()) }; + let recording_here = rec == e.key && !rec_hold; + let label = if recording_here { tl!("Press keys…").to_string() } else { sc.unwrap_or_else(|| "—".into()) }; let changed = crate::keymap::has_override(&saved, &e.key); let txt = egui::RichText::new(label).color(if changed { t.accent } else { t.text }); let b = ui - .add_sized([150.0, 20.0], egui::Button::new(txt).selected(rec == e.key)) + .add_sized([150.0, 20.0], egui::Button::new(txt).selected(recording_here)) .on_hover_text(tl!("Click, then press the new shortcut (Esc cancels)")); if b.clicked() { d.fields.insert("__recording".into(), json!(e.key)); + d.fields.insert("__recordingHold".into(), json!(false)); + d.fields.insert("__selected".into(), json!(e.key)); + } + if !holds_on { + return; + } + let holding_here = rec == e.key && rec_hold; + let hold = hold_of(&holds, &e.key); + let label = if holding_here { + tl!("Press keys…").to_string() + } else { + hold.as_deref().map_or_else(|| "—".into(), menus::pretty_shortcut) + }; + let h = ui.add_sized([90.0, 20.0], egui::Button::new(egui::RichText::new(label).color(t.text)).selected(holding_here)).on_hover_text( + tl!("Click, then press a key to hold for this (Esc cancels). Holding the key runs this; a quick press runs the key's own shortcut."), + ); + if h.clicked() { + d.fields.insert("__recording".into(), json!(e.key)); + d.fields.insert("__recordingHold".into(), json!(true)); d.fields.insert("__selected".into(), json!(e.key)); } }); @@ -1604,6 +1817,10 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) { if ui.button(tl!("Use Default")).clicked() { km.to_mut().reset(&command_of(&sel)); } + if dialog_holds_on(&d) && ui.add_enabled(holds.contains_key(&sel), egui::Button::new(tl!("Clear Hold"))).clicked() { + holds.remove(&sel); + d.fields.insert("set".into(), json!(CUSTOM)); + } }); let conflict = d.str("__conflict"); if !conflict.is_empty() && ui.button(tl!("Go to Conflict")).clicked() { @@ -1622,7 +1839,7 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) { let n = match &km { Cow::Borrowed(_) => view.conflicts, Cow::Owned(km) => conflicts_in(km).len(), - }; + } + if dialog_holds_on(&d) { hold_conflicts(&holds).len() } else { 0 }; if n > 0 { ui.label( egui::RichText::new(crate::i18n::tn( @@ -1648,6 +1865,10 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) { if let Cow::Owned(km) = &km { d.fields.insert("overrides".into(), stored::to_value(&saved_overrides(km.overrides(), &saved))); } + d.fields.insert("holds".into(), json!(holds)); + if d.str("__recording").is_empty() { + d.fields.insert("__recordingHold".into(), json!(false)); + } let import = d.fields.remove("__import").is_some(); let export = d.fields.remove("__export").is_some(); let export_text = d.fields.remove("__exportText").is_some(); @@ -1682,14 +1903,15 @@ fn import_into_dialog(app: &mut VectorcraftApp) { app.status(crate::picks::dialog_gone()); return; } - let saved = (app.ui.shortcut_overrides.clone(), app.ui.shortcut_set.clone()); + let saved = (app.ui.shortcut_overrides.clone(), app.ui.shortcut_holds.clone(), app.ui.shortcut_set.clone()); match run_command(app, "shortcuts.import", &json!({})) { Some(Ok(_)) => { - let (o, s) = (app.ui.shortcut_overrides.clone(), app.ui.shortcut_set.clone()); - (app.ui.shortcut_overrides, app.ui.shortcut_set) = saved; + let (o, h, s) = (app.ui.shortcut_overrides.clone(), app.ui.shortcut_holds.clone(), app.ui.shortcut_set.clone()); + (app.ui.shortcut_overrides, app.ui.shortcut_holds, app.ui.shortcut_set) = saved; sync(&app.ui); if let Some(d) = app.ui.dialog.as_mut().filter(|d| d.kind == "shortcuts") { d.fields.insert("overrides".into(), stored::to_value(&o)); + d.fields.insert("holds".into(), json!(h)); d.fields.insert("set".into(), json!(s)); d.fields.insert("__message".into(), json!(tl!("Imported. Press OK to keep the imported set."))); } @@ -1715,13 +1937,19 @@ fn export_dialog_set(app: &mut VectorcraftApp, command: &str) { app.status(crate::picks::dialog_gone()); return; } - let (ov, set) = app.ui.dialog.as_ref().map(|d| (dialog_overrides(d), d.str("set"))).unwrap_or_default(); + let (ov, holds, set, on) = + app.ui.dialog.as_ref().map(|d| (dialog_overrides(d), dialog_holds(d), d.str("set"), dialog_holds_on(d))).unwrap_or_default(); let saved = std::mem::replace(&mut app.ui.shortcut_overrides, ov); + let saved_holds = std::mem::replace(&mut app.ui.shortcut_holds, holds); let saved_set = std::mem::replace(&mut app.ui.shortcut_set, set); + // Export Text… lists the hold shortcuts while the dialog's Hold Shortcuts is on. + let saved_on = std::mem::replace(&mut app.session.prefs.hold_shortcuts, on); if let Some(Err(e)) = run_command(app, command, &json!({})) { app.status(e); } + app.session.prefs.hold_shortcuts = saved_on; app.ui.shortcut_overrides = saved; + app.ui.shortcut_holds = saved_holds; app.ui.shortcut_set = saved_set; } @@ -1779,6 +2007,107 @@ fn record(d: &mut Dialog, km: &mut Keymap, key: &str, chord: &str) { } } +/// The Hold Shortcuts row of the Keyboard Shortcuts dialog: the checkbox that turns hold shortcuts +/// on (and shows the Hold column), a button that shows how they work, and, while on, the Hold +/// Shortcut Delay. +fn hold_row(ui: &mut egui::Ui, t: &Tokens, d: &mut Dialog) { + ui.horizontal(|ui| { + let mut on = dialog_holds_on(d); + if ui.checkbox(&mut on, egui::RichText::new(tl!("Hold Shortcuts")).color(t.text)).changed() { + d.fields.insert("holdShortcuts".into(), json!(on)); + if !on && d.bool("__recordingHold") { + d.fields.insert("__recording".into(), json!("")); + d.fields.insert("__recordingHold".into(), json!(false)); + } + } + let info = d.bool("__holdInfo"); + if ui + .add(egui::Button::new(egui::RichText::new("?").color(t.text_dim)).selected(info).small()) + .on_hover_text(tl!("How hold shortcuts work")) + .clicked() + { + d.fields.insert("__holdInfo".into(), json!(!info)); + } + if on { + ui.add_space(12.0); + ui.label(egui::RichText::new(tl!("Hold Shortcut Delay")).color(t.text_dim)); + let (min, max) = vectorcraft_engine::KEY_HOLD_DELAY_RANGE; + let mut delay = dialog_hold_delay(d); + if ui.add(egui::DragValue::new(&mut delay).range(min..=max).speed(0.01).fixed_decimals(2).suffix(" s")).changed() { + d.fields.insert("keyHoldDelay".into(), json!(delay)); + } + } + }); + if d.bool("__holdInfo") { + egui::Frame::NONE.stroke(egui::Stroke::new(1.0, t.input_border)).inner_margin(egui::Margin::same(8)).show(ui, |ui| { + ui.horizontal(|ui| { + hold_illustration(ui, t); + ui.add_space(8.0); + ui.add( + egui::Label::new( + egui::RichText::new(tl!( + "A quick press of a key runs its shortcut. Holding the key for the delay runs the tool or command in its Hold column instead. A hold shortcut is a letter, digit or punctuation key, alone or with Shift." + )) + .color(t.text) + .size(11.5), + ) + .wrap(), + ); + }); + }); + } +} + +/// A key and two presses of it drawn in code: a short press (Tap) ends before the delay, and a long +/// one (Hold) reaches it. +fn hold_illustration(ui: &mut egui::Ui, t: &Tokens) { + let (rect, _) = ui.allocate_exact_size(egui::vec2(200.0, 52.0), egui::Sense::hover()); + let p = ui.painter_at(rect); + let key = egui::Rect::from_min_size(rect.min + egui::vec2(2.0, 12.0), egui::vec2(28.0, 28.0)); + p.rect(key, 4.0, t.input, egui::Stroke::new(1.0, t.input_border), egui::StrokeKind::Inside); + p.text(key.center(), egui::Align2::CENTER_CENTER, "X", egui::FontId::proportional(13.0), t.text); + let start = key.right() + 10.0; + let delay_x = start + 70.0; + let rows = [(tl!("Tap"), 40.0, key.top() + 6.0), (tl!("Hold"), 100.0, key.bottom() - 6.0)]; + for (label, len, y) in rows { + let color = if start + len >= delay_x { t.accent } else { t.text_dim }; + p.line_segment([egui::pos2(start, y), egui::pos2(start + len, y)], egui::Stroke::new(4.0, color)); + p.text(egui::pos2(start + len + 4.0, y), egui::Align2::LEFT_CENTER, label, egui::FontId::proportional(10.5), t.text); + } + // The delay. + let mut y = rect.top() + 4.0; + while y < rect.bottom() - 4.0 { + p.line_segment([egui::pos2(delay_x, y), egui::pos2(delay_x, (y + 3.0).min(rect.bottom() - 4.0))], egui::Stroke::new(1.0, t.text_dim)); + y += 6.0; + } +} + +/// Apply a recorded key as `key`'s hold shortcut in the working set. Another entry that held the +/// key loses it, with the same warning as a shortcut; a key that can't hold says why. +fn record_hold(d: &mut Dialog, holds: &mut Holds, key: &str, chord: &str) { + d.fields.insert("__recording".into(), json!("")); + d.fields.insert("__recordingHold".into(), json!(false)); + match assign_hold(holds, key, Some(chord), true) { + Ok(removed) => { + d.fields.insert("set".into(), json!(CUSTOM)); + let names: Vec = removed.iter().map(|k| entry(k).map(|e| shown_name(&e)).unwrap_or(k.clone())).collect(); + let message = if names.is_empty() { + String::new() + } else { + crate::i18n::fmt( + tl!("⚠ {chord} was already used by {names} — it has been removed there."), + &[("chord", &menus::pretty_shortcut(chord)), ("names", &names.join(", "))], + ) + }; + d.fields.insert("__message".into(), json!(message)); + d.fields.insert("__conflict".into(), json!("")); + } + Err(e) => { + d.fields.insert("__message".into(), json!(e)); + } + } +} + #[cfg(test)] mod tests { use super::*; @@ -2839,4 +3168,168 @@ mod tests { assert_eq!(r["shortcut"], "Cmd+Alt+Shift+F11"); assert!(app.run("shortcuts.preset", json!({"name": null})).unwrap_err().starts_with("unknown preset")); } + + /// `shortcuts.set {hold}` gives an entry a hold shortcut and leaves its shortcut, its default + /// and its overridden state alone; `shortcuts.list` shows it; Clear (`shortcut: null`) keeps it. + #[test] + fn a_hold_shortcut_is_kept_apart_from_the_shortcut() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + let before = effective_in(&app.ui.shortcut_overrides, "paint.swap"); + let r = app.run("shortcuts.set", json!({"id": "paint.swap", "hold": "x"})).unwrap(); + assert_eq!((r["hold"].as_str(), r["shortcut"].as_str().map(str::to_string)), (Some("X"), before.clone())); + assert!(app.ui.shortcut_overrides.is_empty(), "no shortcut changed"); + assert_eq!(app.ui.shortcut_set, CUSTOM); + let rows = with_steady_plugins(|| app.run("shortcuts.list", json!({"query": "paint.swap"})).unwrap()); + let row = rows.as_array().unwrap().iter().find(|r| r["id"] == "paint.swap").unwrap().clone(); + assert_eq!((row["hold"].as_str(), row["overridden"].as_bool()), (Some("X"), Some(false))); + app.run("shortcuts.set", json!({"id": "paint.swap", "shortcut": null})).unwrap(); + assert_eq!(hold_of(&app.ui.shortcut_holds, "paint.swap").as_deref(), Some("X"), "Use Default keeps the hold"); + app.run("shortcuts.set", json!({"id": "paint.swap", "shortcut": "Cmd+Alt+Shift+F9"})).unwrap(); + assert_eq!(hold_of(&app.ui.shortcut_holds, "paint.swap").as_deref(), Some("X"), "a new shortcut keeps the hold"); + app.run("shortcuts.set", json!({"id": "paint.swap", "hold": ""})).unwrap(); + assert!(app.ui.shortcut_holds.is_empty(), "an empty hold removes it"); + app.run("shortcuts.set", json!({"id": "paint.swap", "hold": "Shift+1"})).unwrap(); + app.run("shortcuts.set", json!({"id": "paint.swap", "hold": null})).unwrap(); + assert!(app.ui.shortcut_holds.is_empty(), "a null hold removes it"); + } + + /// A hold shortcut is a key that types a character, alone or with Shift; other keys, a clash + /// without `force` and a hold that is not a string are refused and change nothing. + #[test] + fn hold_shortcuts_refuse_keys_that_cannot_wait() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + for bad in ["Space", "Shift+Space", "~", "Shift+~", "Cmd+X", "Alt+X", "Ctrl+X", "Left", "F5", "Enter", "Delete"] { + let r = app.run("shortcuts.set", json!({"id": "paint.swap", "hold": bad})); + assert!(r.is_err(), "{bad}: {r:?}"); + } + assert_eq!(app.run("shortcuts.set", json!({"id": "paint.swap", "hold": 5})), Err("`hold` must be a string".to_string())); + assert!(app.ui.shortcut_holds.is_empty()); + app.run("shortcuts.set", json!({"id": "paint.swap", "hold": "Shift+X"})).unwrap(); + let clash = app.run("shortcuts.set", json!({"id": "select.none", "hold": "Shift+X"})).unwrap_err(); + assert!(clash.starts_with("Hold "), "{clash}"); + // A refused hold leaves the shortcut given with it unchanged too. + let r = app.run("shortcuts.set", json!({"id": "select.none", "shortcut": "Cmd+Alt+Shift+F9", "hold": "Shift+X"})); + assert!(r.is_err()); + assert!(app.ui.shortcut_overrides.is_empty()); + let r = app.run("shortcuts.set", json!({"id": "select.none", "hold": "Shift+X", "force": true})).unwrap(); + assert_eq!(r["removedFrom"], json!(["paint.swap"])); + assert_eq!(app.ui.shortcut_holds.keys().collect::>(), ["select.none"]); + } + + /// Reset All and a preset clear the hold shortcuts; two entries holding one key are a conflict. + #[test] + fn hold_shortcut_conflicts_reset_and_presets() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.ui.shortcut_holds.insert("paint.swap".into(), "X".into()); + app.ui.shortcut_holds.insert("select.none".into(), "X".into()); + let c = app.run("shortcuts.conflicts", json!({})).unwrap(); + assert!(c.as_array().unwrap().iter().any(|c| c["shortcut"] == "Hold X"), "{c}"); + app.run("shortcuts.reset", json!({})).unwrap(); + assert!(app.ui.shortcut_holds.is_empty()); + app.run("shortcuts.set", json!({"id": "paint.swap", "hold": "X"})).unwrap(); + app.run("shortcuts.preset", json!({"name": PRESETS[0]})).unwrap(); + assert!(app.ui.shortcut_holds.is_empty()); + } + + /// Export… writes the hold shortcuts as `holds` (version 1) only when there are any; Import… + /// reads them, a file without them has none, and a bad one fails and applies nothing. + #[test] + fn hold_shortcuts_export_and_import() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + let none = export_json("Studio", &Overrides::new()); + assert!(none.get("holds").is_none()); + let holds: Holds = [("paint.swap".to_string(), "X".to_string())].into(); + let v = export_json_with("Studio", &Overrides::new(), &holds); + assert_eq!((v["version"].as_u64(), v["holds"].clone()), (Some(1), json!({"paint.swap": "X"}))); + app.run("shortcuts.import", json!({"data": v})).unwrap(); + assert_eq!(app.ui.shortcut_holds, holds); + for bad in [json!("X"), json!({"paint.swap": 5}), json!({"paint.swap": "Space"})] { + let mut v = export_json("Other", &Overrides::new()); + v["holds"] = bad.clone(); + assert!(app.run("shortcuts.import", json!({"data": v})).is_err(), "{bad}"); + assert_eq!((app.ui.shortcut_holds.clone(), app.ui.shortcut_set.as_str()), (holds.clone(), "Studio"), "{bad}"); + } + app.run("shortcuts.import", json!({"data": none})).unwrap(); + assert!(app.ui.shortcut_holds.is_empty(), "an import replaces the whole set"); + } + + /// Export Text… gives a row with a hold shortcut a third column while Hold Shortcuts is on. + #[test] + fn export_text_lists_hold_shortcuts_while_they_act() { + type Files = std::rc::Rc>>; + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + let written: Files = Default::default(); + let w = written.clone(); + app.services.write = Some(Box::new(move |_: &str, b: &[u8]| { + w.borrow_mut().push(String::from_utf8(b.to_vec()).map_err(|e| e.to_string())?); + Ok(()) + })); + app.run("shortcuts.set", json!({"id": "paint.swap", "hold": "X"})).unwrap(); + let row = |text: &str| text.lines().find(|l| l.starts_with(&english_name(&entry("paint.swap").unwrap()))).map(str::to_string); + with_steady_plugins(|| { + written.borrow_mut().clear(); + app.run("shortcuts.exportText", json!({"path": "/a.txt"})).unwrap(); + app.run("prefs.set", json!({"key": "holdShortcuts", "value": true})).unwrap(); + app.run("shortcuts.exportText", json!({"path": "/b.txt"})).unwrap(); + app.run("prefs.set", json!({"key": "holdShortcuts", "value": false})).unwrap(); + }); + let files = written.borrow(); + let (off, on) = (row(&files[0]).unwrap(), row(&files[1]).unwrap()); + assert_eq!(off.split('\t').count(), 2, "{off}"); + assert_eq!(on.split('\t').nth(2), Some(format!("Hold {}", menus::pretty_shortcut("X")).as_str()), "{on}"); + } + + /// The text the Keyboard Shortcuts dialog draws in its second frame. + fn dialog_texts(app: &mut VectorcraftApp) -> Vec { + let ctx = egui::Context::default(); + theme::install_fonts(&ctx); + // The modal draws nothing in its first frame, which only sizes it. + let mut out = ctx.run_ui(egui::RawInput::default(), |ui| show(app, ui.ctx())); + out.textures_delta.clear(); + let mut out = ctx.run_ui(egui::RawInput::default(), |ui| show(app, ui.ctx())); + out.textures_delta.clear(); + out.shapes + .iter() + .filter_map(|c| match &c.shape { + egui::Shape::Text(t) => Some(t.galley.text().to_string()), + _ => None, + }) + .collect() + } + + /// Hold Shortcuts is off by default: the dialog shows its checkbox and no Hold column. Turned + /// on, the dialog shows the column and the delay, and OK turns hold shortcuts on; Cancel keeps + /// them off. + #[test] + fn the_hold_shortcuts_checkbox_shows_the_hold_column() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + assert!(!app.session.prefs.hold_shortcuts); + open(&mut app); + let off = dialog_texts(&mut app); + assert!(off.iter().any(|t| t == "Hold Shortcuts"), "{off:?}"); + assert!(!off.iter().any(|t| t == "Hold" || t == "Hold Shortcut Delay"), "{off:?}"); + app.ui.dialog.as_mut().unwrap().fields.insert("holdShortcuts".into(), json!(true)); + let on = dialog_texts(&mut app); + assert!(on.iter().any(|t| t == "Hold") && on.iter().any(|t| t == "Hold Shortcut Delay"), "{on:?}"); + app.ui.dialog = None; + assert!(!app.session.prefs.hold_shortcuts, "Cancel keeps them off"); + open(&mut app); + let d = app.ui.dialog.as_mut().unwrap(); + d.fields.insert("holdShortcuts".into(), json!(true)); + d.fields.insert("keyHoldDelay".into(), json!(0.5)); + confirm(&mut app).unwrap(); + assert!(app.session.prefs.hold_shortcuts); + assert_eq!(app.session.prefs.key_hold_delay, 0.5); + } + + /// The info button shows how hold shortcuts work. + #[test] + fn the_info_button_explains_hold_shortcuts() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + open(&mut app); + assert!(!dialog_texts(&mut app).iter().any(|t| t.starts_with("A quick press"))); + app.ui.dialog.as_mut().unwrap().fields.insert("__holdInfo".into(), json!(true)); + let texts = dialog_texts(&mut app); + assert!(texts.iter().any(|t| t.starts_with("A quick press")) && texts.iter().any(|t| t == "Tap"), "{texts:?}"); + } } diff --git a/crates/ui-egui/src/shortcuts.rs b/crates/ui-egui/src/shortcuts.rs index d102c40d7e..257e63ecfc 100644 --- a/crates/ui-egui/src/shortcuts.rs +++ b/crates/ui-egui/src/shortcuts.rs @@ -12,11 +12,13 @@ use vectorcraft_tools::{Mods, SurroundingUnit, ToolKey}; use crate::VectorcraftApp; mod held_tool; +mod hold_keys; mod paste; mod presentation; mod typing; pub(crate) use held_tool::{HeldTool, note_tool_use}; +pub(crate) use hold_keys::HoldKeys; use paste::unclip_chords; pub(crate) use paste::{PasteChord, paste_command}; pub(crate) use presentation::presentation_step; @@ -196,6 +198,8 @@ pub fn handle(app: &mut VectorcraftApp, ctx: &egui::Context) { note_key_surfaces(app, ctx); forget_opening_key(ctx); let focused = ctx.input(|input| input.focused) || app.forwarded_frame && ctx.viewport_id() == egui::ViewportId::ROOT; + // The repeats of a key with a hold shortcut stay out of every frame until it is let go. + hold_keys::guard(app, ctx, focused); // A held tool shortcut that is let go returns to the tool active before it. held_tool::follow(app, ctx, focused); if !focused { @@ -243,6 +247,11 @@ pub fn handle(app: &mut VectorcraftApp, ctx: &egui::Context) { presentation_keys(app, ctx); return; } + // Keys with a hold shortcut wait before anything else reads the frame's keys, so a key pressed + // after one acts after it. + if hold_keys::intake(app, ctx) { + return; + } // Escape that cancels a ruler-origin drag or floating Tools move skips the tool and later Escape actions, // and so do its repeats while it is held. let escape_ended_gesture = escape_ended_gesture(ctx); @@ -580,42 +589,60 @@ fn single_key_shortcuts(app: &mut VectorcraftApp, ctx: &egui::Context) { }) .collect() }); - let keymap = crate::shortcut_editor::current(); for (text, m, pressed, repeat) in events { if m.command || m.alt || m.ctrl { continue; } - let upper = text.to_uppercase(); - let key = if m.shift && text.chars().all(|c| c.is_alphabetic()) { format!("Shift+{upper}") } else { upper.clone() }; - // A shifted punctuation character can also be written with its Shift (the Curvature tool's - // Shift+~ arrives as `~`). - let shifted = m.shift.then(|| format!("Shift+{text}")); - let mut chords: Vec = - [Some(key), Some(text), shifted].into_iter().flatten().filter_map(|t| crate::keymap::vc_chord(&t)).collect(); - // A character no chord names (`"`, which the backtick key types on Turkish Q) is read as - // the key that typed it, as the Keyboard Shortcuts editor records that press. - if chords.is_empty() { - let typed_by = pressed.and_then(|k| crate::shortcut_editor::chord_from_event(k, Modifiers { shift: m.shift, ..Modifiers::NONE })); - chords.extend(typed_by.and_then(|t| crate::keymap::vc_chord(&t))); + let chords = text_chords(&text, m, pressed); + if run_single_key(app, ctx, &chords, pressed, repeat) { + break; } - let hits: Vec = chords.iter().filter_map(|c| crate::keymap::lookup(&keymap.keymap, c)).collect(); - // Single-key command shortcuts (X, Shift+X, D, /, Shift+D, F, Shift+F by default) before - // tools. - let Some(hit) = hits.iter().find(|c| !c.id.starts_with("tool:")).or(hits.first()) else { continue }; - // A command runs as it does on a chord ([`run_hit`]): what its menu item runs. Smooth opens - // its slider, and Move opens its dialog. - match hit.id.strip_prefix("tool:") { - Some(tool) => held_tool::choose(app, ctx, tool, pressed, repeat), - None => { - run_hit(app, ctx, hit); - if dialog_or_palette_open(app) { - if let Some(key) = pressed { - let id = opening_key_id(ctx); - ctx.data_mut(|m| m.insert_temp(id, key)); - } - break; - } + } +} + +/// The chords a single-key shortcut reads for `text`, typed with `m` by the key `pressed`. +fn text_chords(text: &str, m: Modifiers, pressed: Option) -> Vec { + let upper = text.to_uppercase(); + let key = if m.shift && text.chars().all(|c| c.is_alphabetic()) { format!("Shift+{upper}") } else { upper.clone() }; + // A shifted punctuation character can also be written with its Shift (the Curvature tool's + // Shift+~ arrives as `~`). + let shifted = m.shift.then(|| format!("Shift+{text}")); + let mut chords: Vec = + [Some(key), Some(text.to_string()), shifted].into_iter().flatten().filter_map(|t| crate::keymap::vc_chord(&t)).collect(); + // A character no chord names (`"`, which the backtick key types on Turkish Q) is read as + // the key that typed it, as the Keyboard Shortcuts editor records that press. + if chords.is_empty() { + let typed_by = pressed.and_then(|k| crate::shortcut_editor::chord_from_event(k, Modifiers { shift: m.shift, ..Modifiers::NONE })); + chords.extend(typed_by.and_then(|t| crate::keymap::vc_chord(&t))); + } + chords +} + +/// Runs the single-key shortcut of `chords`, typed by the key `pressed`. True when it opened a +/// dialog or the palette: the shortcuts after it in the frame do not run. +fn run_single_key(app: &mut VectorcraftApp, ctx: &egui::Context, chords: &[craft_keymap::Chord], pressed: Option, repeat: bool) -> bool { + let keymap = crate::shortcut_editor::current(); + let hits: Vec = chords.iter().filter_map(|c| crate::keymap::lookup(&keymap.keymap, c)).collect(); + // Single-key command shortcuts (X, Shift+X, D, /, Shift+D, F, Shift+F by default) before + // tools. + let Some(hit) = hits.iter().find(|c| !c.id.starts_with("tool:")).or(hits.first()) else { return false }; + // A command runs as it does on a chord ([`run_hit`]): what its menu item runs. Smooth opens + // its slider, and Move opens its dialog. + match hit.id.strip_prefix("tool:") { + Some(tool) => { + held_tool::choose(app, ctx, tool, pressed, repeat); + false + } + None => { + run_hit(app, ctx, hit); + if !dialog_or_palette_open(app) { + return false; } + if let Some(key) = pressed { + let id = opening_key_id(ctx); + ctx.data_mut(|m| m.insert_temp(id, key)); + } + true } } } @@ -1077,7 +1104,7 @@ fn run_hit(app: &mut VectorcraftApp, ctx: &egui::Context, c: &CommandRef) { } /// Keys that type a character: letters, digits and punctuation (not Space). -fn types_text(key: craft_keymap::Key) -> bool { +pub(crate) fn types_text(key: craft_keymap::Key) -> bool { key.name().chars().count() == 1 } diff --git a/crates/ui-egui/src/shortcuts/hold_keys.rs b/crates/ui-egui/src/shortcuts/hold_keys.rs new file mode 100644 index 0000000000..eb7c92ab04 --- /dev/null +++ b/crates/ui-egui/src/shortcuts/hold_keys.rs @@ -0,0 +1,321 @@ +//! Hold shortcuts (Edit › Keyboard Shortcuts, Hold Shortcuts on, the Hold column): a character key +//! with a hold shortcut waits when it goes down. Held for the Hold Shortcut Delay (`keyHoldDelay`), +//! it runs its hold shortcut once, and its repeats are ignored until it is let go. Let go sooner, it +//! runs what a press of the key runs without a hold shortcut, at the release. A key without a hold +//! shortcut runs on its press, as before, and so does every key while Hold Shortcuts is off. + +use super::{Key, Modifiers, VectorcraftApp}; +use vectorcraft_tools::ToolKey; + +/// A press of a key with a hold shortcut, waiting for its release or for the delay to pass. +pub(crate) struct Pending { + /// The entry the hold shortcut runs (`tool:`, a command id or `panel:`). + entry: String, + /// The chords the press names, first match first, for the tap. + chords: Vec, + /// The key as egui reported the press, before any rewrite of the dispatcher. + key: Key, + /// The key's position, when the press gave one. + physical: Option, + /// The modifiers held at the press. + mods: Modifiers, + /// When the key went down (`egui::InputState::time`). + since: f64, + /// The Hold Shortcut Delay read at the press: a later change does not move this wait. + delay: f64, + /// The viewport whose frame saw the press. Frames of other viewports leave the wait alone. + viewport: egui::ViewportId, +} + +/// A key whose repeats, and the text they type, are dropped until it is let go. +#[derive(Clone, Copy, PartialEq)] +struct Swallowed { + key: Key, + physical: Option, + viewport: egui::ViewportId, +} + +/// The hold shortcut state of the app: at most one waiting press, and the keys held down after +/// their wait ended. +#[derive(Default)] +pub(crate) struct HoldKeys { + pending: Option, + swallowed: Vec, +} + +/// Is `e` the release of the key `key` at `physical`? The position decides when both events give +/// one; otherwise the key decides. +fn releases(e: &egui::Event, key: Key, physical: Option) -> bool { + matches!(e, egui::Event::Key { key: k, physical_key: p, pressed: false, .. } if same_key(*k, *p, key, physical)) +} + +fn same_key(k: Key, p: Option, key: Key, physical: Option) -> bool { + match (p, physical) { + (Some(p), Some(q)) => p == q, + _ => k == key || Some(k) == physical, + } +} + +/// Is the key still down? egui keeps the keys down by the key it reported for the press. +fn is_down(i: &egui::InputState, key: Key, physical: Option) -> bool { + i.key_down(key) || physical.is_some_and(|p| i.key_down(p)) +} + +/// What stops a wait: anything that takes the keyboard from the canvas. +fn blocked(app: &VectorcraftApp, ctx: &egui::Context) -> bool { + crate::scrub::phase(ctx) != crate::scrub::Phase::Idle + || crate::updates_ui::blocks_input(app) + || app.ui.dialog.is_some() + || app.ui.palette_open + || app.ui.screen_mode == 3 + || ctx.egui_wants_keyboard_input() + || app.session.tool_wants_text() + || app.session.tool_composing() + || app.session.tool_busy() + // An input method composing on the canvas with any tool. + || ctx.input(|i| i.events.iter().any(|e| matches!(e, egui::Event::Ime(egui::ImeEvent::Preedit { text, .. }) if !text.is_empty()))) +} + +/// Every frame, before anything can return: drops the repeats of the keys held after their wait +/// ended or while it waits, and the text they type, also on frames that run no shortcut. Ends the +/// wait without running anything when the window lost the keyboard, or when a field, a dialog, +/// Presentation Mode, a numeric scrub, an IME composition or a busy tool has it. +pub(super) fn guard(app: &mut VectorcraftApp, ctx: &egui::Context, focused: bool) { + let viewport = ctx.viewport_id(); + if !focused { + // egui lets go of every key when the window loses the keyboard. + if app.hold_keys.pending.as_ref().is_some_and(|p| p.viewport == viewport) { + app.hold_keys.pending = None; + } + app.hold_keys.swallowed.retain(|s| s.viewport != viewport); + return; + } + if app.hold_keys.pending.as_ref().is_some_and(|p| p.viewport == viewport) && (blocked(app, ctx) || !app.session.prefs.hold_shortcuts) { + cancel(app, ctx); + } + let mut held: Vec<(Key, Option)> = app.hold_keys.swallowed.iter().filter(|s| s.viewport == viewport).map(|s| (s.key, s.physical)).collect(); + held.extend(app.hold_keys.pending.as_ref().filter(|p| p.viewport == viewport).map(|p| (p.key, p.physical))); + if held.is_empty() { + return; + } + drop_repeats(ctx, &held); + // A key let go, or pressed anew, is no longer held back after this frame: a repeat that came + // in the same frame as its release was dropped above. + ctx.input(|i| { + app.hold_keys.swallowed.retain(|s| { + s.viewport != viewport + || is_down(i, s.key, s.physical) + && !i.events.iter().any(|e| { + releases(e, s.key, s.physical) + || matches!(e, egui::Event::Key { key, physical_key, pressed: true, repeat: false, .. } if same_key(*key, *physical_key, s.key, s.physical)) + }) + }); + }); +} + +/// Removes this frame's repeats of the keys `held`, and the text they type. +fn drop_repeats(ctx: &egui::Context, held: &[(Key, Option)]) { + let repeat = |e: Option<&egui::Event>| { + matches!(e, Some(egui::Event::Key { key, physical_key, pressed: true, repeat: true, .. }) + if held.iter().any(|(k, p)| same_key(*key, *physical_key, *k, *p))) + }; + ctx.input_mut(|i| { + let typed_by = super::typing_presses(&i.events); + let drop: Vec = i + .events + .iter() + .zip(typed_by) + .map(|(e, by)| repeat(Some(e)) || matches!(e, egui::Event::Text(_)) && repeat(by.and_then(|k| i.events.get(k)))) + .collect(); + let mut drop = drop.into_iter(); + i.events.retain(|_| !drop.next().unwrap_or(false)); + }); +} + +/// Ends the wait without running anything; the key's repeats stay held back until it is let go. +fn cancel(app: &mut VectorcraftApp, ctx: &egui::Context) { + let Some(p) = app.hold_keys.pending.take() else { return }; + if ctx.input(|i| is_down(i, p.key, p.physical)) { + app.hold_keys.swallowed.push(Swallowed { key: p.key, physical: p.physical, viewport: p.viewport }); + } +} + +/// Runs the result of the wait: the hold shortcut when `hold`, otherwise the tap. `down`: the key +/// is still down, so its repeats are held back until it is let go. True when the result opened a +/// dialog or the palette. +fn settle(app: &mut VectorcraftApp, ctx: &egui::Context, hold: bool, down: bool) -> bool { + let Some(p) = app.hold_keys.pending.take() else { return false }; + if down { + app.hold_keys.swallowed.push(Swallowed { key: p.key, physical: p.physical, viewport: p.viewport }); + } + if hold { + super::run_hit(app, ctx, &crate::keymap::command_of(&p.entry)); + } else { + // The key is already up, or another key went down: a tool it chooses is chosen for good. + super::run_single_key(app, ctx, &p.chords, None, false); + } + let opened = super::dialog_or_palette_open(app); + if opened && down { + // The key's repeats do not reach the dialog. + let id = super::opening_key_id(ctx); + ctx.data_mut(|m| m.insert_temp(id, p.key)); + } + opened +} + +/// The chords a press names for a hold shortcut, first match first: those of the text it typed, as +/// a single-key shortcut reads them, then the key itself with its Shift (Shift+1 typing `!`). A +/// letter names only the chord with its own Shift state: a hold on X does not catch Shift+X. +fn press_chords(text: &str, key: Key, m: Modifiers) -> Vec { + let mut chords = super::text_chords(text, m, Some(key)); + if !text.is_empty() && text.chars().all(char::is_alphabetic) { + chords.retain(|c| c.mods.shift == m.shift); + } + let shift = Modifiers { shift: m.shift, ..Modifiers::NONE }; + if let Some(c) = crate::shortcut_editor::chord_from_event(key, shift).and_then(|t| crate::keymap::vc_chord(&t)) + && !chords.contains(&c) + { + chords.push(c); + } + chords +} + +/// The chords a quick press runs, as the key runs without a hold shortcut: a shortcut on a shifted +/// punctuation key itself (Shift+.), which the shortcuts read from the key press, then those of +/// the text it typed. +fn tap_chords(text: &str, key: Key, m: Modifiers) -> Vec { + let shift = Modifiers { shift: m.shift, ..Modifiers::NONE }; + let pressed = crate::shortcut_editor::chord_from_event(key, shift) + .and_then(|t| crate::keymap::vc_chord(&t)) + .filter(|c| c.mods.shift && c.key.name().chars().all(|ch| !ch.is_alphanumeric())); + let mut chords: Vec = super::text_chords(text, m, Some(key)).into_iter().filter(|c| pressed.as_ref() != Some(c)).collect(); + if let Some(c) = pressed { + chords.insert(0, c); + } + chords +} + +/// Does the active tool take this key itself (a digit with the perspective grid showing, a bracket +/// with the Blob Brush, E with the Extend Path tool)? Then the key keeps doing that and does not +/// wait. +fn tool_takes(app: &mut VectorcraftApp, key: Key, text: &str) -> bool { + let view = app.view_info(); + let tool_key = match text { + "[" | "{" => Some(ToolKey::BracketLeft), + "]" | "}" => Some(ToolKey::BracketRight), + _ => super::digit_of(key).map(ToolKey::Digit).or_else(|| super::letter_of(key).map(ToolKey::Letter)), + }; + tool_key.is_some_and(|k| app.session.tool_claims_key(k, view)) +} + +/// Before the frame's shortcuts run: goes through the frame's events in order. A release of the +/// waiting key ends the wait (the hold when the delay has passed, otherwise the tap); a press of +/// another key, or a change of Cmd, Ctrl or Alt, ends it first, so the keys act in the order they +/// went down; and a new press of a key with a hold shortcut starts a wait, taking the press and +/// its text from the frame. Then a wait whose delay has passed with the key down runs the hold +/// shortcut. True when a result opened a dialog or the palette: the rest of the frame's keys are +/// dropped and no other shortcut runs. +pub(super) fn intake(app: &mut VectorcraftApp, ctx: &egui::Context) -> bool { + // Off (Keyboard Shortcuts › Hold Shortcuts), every key runs on its press. + if !app.session.prefs.hold_shortcuts || blocked(app, ctx) { + return false; + } + let viewport = ctx.viewport_id(); + let (events, now) = ctx.input(|i| (i.events.clone(), i.time)); + let typed_by = super::typing_presses(&events); + let text_of = |k: usize| typed_by.iter().position(|by| *by == Some(k)).and_then(|j| events.get(j).map(|e| (j, e))); + let mut taken: Vec = vec![]; + let mut stop_at = None; + for (j, e) in events.iter().enumerate() { + if let Some(p) = app.hold_keys.pending.as_ref().filter(|p| p.viewport == viewport) { + let overdue = now - p.since >= p.delay; + let ended = if releases(e, p.key, p.physical) { + Some((overdue, false)) + } else { + match e { + egui::Event::Key { key, physical_key, pressed: true, .. } + if !super::is_modifier(*key) && !same_key(*key, *physical_key, p.key, p.physical) => + { + Some((overdue, true)) + } + // A new press of the waiting key whose release was never seen. + egui::Event::Key { key, physical_key, pressed: true, repeat: false, .. } if same_key(*key, *physical_key, p.key, p.physical) => { + Some((false, false)) + } + egui::Event::ModifiersChanged(m) if (m.command, m.ctrl, m.alt) != (p.mods.command, p.mods.ctrl, p.mods.alt) => { + Some((false, true)) + } + _ => None, + } + }; + if let Some((hold, down)) = ended + && settle(app, ctx, hold, down) + { + stop_at = Some(j); + break; + } + } + let egui::Event::Key { key, physical_key, pressed: true, repeat: false, modifiers: m } = e else { continue }; + if m.command || m.ctrl || m.alt || m.mac_cmd || super::is_modifier(*key) { + continue; + } + // Only a press that typed a text waits: a text alone has no key to let go. + let Some((t, egui::Event::Text(text))) = text_of(j) else { continue }; + let typed = super::latin(text, *physical_key); + let Some(entry) = + press_chords(&typed, *key, *m).iter().find_map(|c| crate::shortcut_editor::hold_for(&app.ui.shortcut_holds, c)).map(str::to_string) + else { + continue; + }; + let chords = tap_chords(&typed, *key, *m); + if tool_takes(app, *key, text) { + continue; + } + taken.extend([j, t]); + // A wait left in another viewport ends without running: that window lost the keyboard to + // this one. Its key's repeats stay held back there until it is let go. + if let Some(old) = app.hold_keys.pending.take_if(|p| p.viewport != viewport) { + app.hold_keys.swallowed.push(Swallowed { key: old.key, physical: old.physical, viewport: old.viewport }); + } + let delay = app.session.prefs.key_hold_delay(); + app.hold_keys.pending = Some(Pending { entry, chords, key: *key, physical: *physical_key, mods: *m, since: now, delay, viewport }); + } + // Take the waiting presses and their texts, and after a result that opened a dialog, the key + // event that ended the wait and every later key event and text of the frame, with the text a + // press typed before it (the web build sends a press's text first): none of them reaches the + // dialog. + ctx.input_mut(|i| { + if i.events.len() != events.len() { + return; + } + let mut j = 0; + i.events.retain(|e| { + let k = j; + j += 1; + let later = stop_at.is_some_and(|s| { + k >= s && matches!(e, egui::Event::Key { .. } | egui::Event::Text(_)) + || matches!(e, egui::Event::Text(_)) && typed_by.get(k).copied().flatten().is_some_and(|by| by >= s) + }); + !(taken.contains(&k) || later) + }); + }); + if stop_at.is_some() { + return true; + } + let Some(p) = app.hold_keys.pending.as_ref().filter(|p| p.viewport == viewport) else { return false }; + let deadline = p.since + p.delay; + let down = ctx.input(|i| is_down(i, p.key, p.physical)); + if !down { + // Let go without a release this frame saw. + return settle(app, ctx, now >= deadline, false); + } + if now >= deadline { + return settle(app, ctx, true, true); + } + // egui draws only on input, and a held key need not repeat: draw again at the deadline. + ctx.request_repaint_after_secs((deadline - now) as f32); + false +} + +#[cfg(test)] +mod tests; diff --git a/crates/ui-egui/src/shortcuts/hold_keys/tests.rs b/crates/ui-egui/src/shortcuts/hold_keys/tests.rs new file mode 100644 index 0000000000..be7765f8f3 --- /dev/null +++ b/crates/ui-egui/src/shortcuts/hold_keys/tests.rs @@ -0,0 +1,517 @@ +use serde_json::json; + +use super::super::handle; +use super::*; + +/// A keyboard on one context, so egui keeps the keys held down from frame to frame and marks a +/// held key's later presses as repeats, with the frame times the test sets. +struct Keyboard { + ctx: egui::Context, +} + +impl Keyboard { + fn new() -> Self { + Self { ctx: egui::Context::default() } + } + + /// One frame at `time` seconds delivering `events`, with the window having the keyboard + /// (`focused`) or not. + fn frame_with_focus(&self, app: &mut VectorcraftApp, time: f64, events: Vec, focused: bool) { + let screen_rect = Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(800.0, 600.0))); + let mut out = self.ctx.run_ui(egui::RawInput { events, screen_rect, time: Some(time), focused, ..Default::default() }, |ui| { + app.logic(ui.ctx()); + handle(app, ui.ctx()); + }); + out.textures_delta.clear(); + } + + fn frame(&self, app: &mut VectorcraftApp, time: f64, events: Vec) { + self.frame_with_focus(app, time, events, true); + } + + /// [`Self::frame`], giving the events the shortcuts left in the first pass for what is drawn + /// after them. + fn frame_left(&self, app: &mut VectorcraftApp, time: f64, events: Vec) -> Vec { + let screen_rect = Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(800.0, 600.0))); + let mut left = None; + let mut out = self.ctx.run_ui(egui::RawInput { events, screen_rect, time: Some(time), focused: true, ..Default::default() }, |ui| { + app.logic(ui.ctx()); + handle(app, ui.ctx()); + if left.is_none() { + left = Some(ui.ctx().input(|i| i.events.clone())); + } + }); + out.textures_delta.clear(); + left.unwrap_or_default() + } + + /// `key` pressed (a repeat when it is already down) at `time`, typing `text`. + fn press(&self, app: &mut VectorcraftApp, time: f64, key: Key, text: &str) { + self.frame(app, time, press(key, text, Modifiers::NONE)); + } + + fn release(&self, app: &mut VectorcraftApp, time: f64, key: Key) { + self.frame(app, time, vec![release(key)]); + } +} + +fn press(key: Key, text: &str, modifiers: Modifiers) -> Vec { + vec![egui::Event::Key { key, physical_key: Some(key), pressed: true, repeat: false, modifiers }, egui::Event::Text(text.into())] +} + +fn release(key: Key) -> egui::Event { + egui::Event::Key { key, physical_key: Some(key), pressed: false, repeat: false, modifiers: Modifiers::NONE } +} + +/// A document with a selected rectangle filled red with a blue stroke, the Pen tool chosen, and +/// Hold Shortcuts `on`. +fn app_with(on: bool) -> VectorcraftApp { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + crate::shortcut_editor::sync(&app.ui); + app.run("file.new", json!({"width": 400, "height": 300})).unwrap(); + app.run("shape.rectangle", json!({"x": 100, "y": 100, "width": 100, "height": 50})).unwrap(); + app.run("paint.setFill", json!({"color": "#ff0000"})).unwrap(); + app.run("paint.setStroke", json!({"color": "#0000ff"})).unwrap(); + app.run("prefs.set", json!({"key": "holdShortcuts", "value": on})).unwrap(); + app.select_tool("pen"); + app +} + +/// erolka's X: a quick press chooses the Eyedropper, and holding X swaps fill and stroke. +fn erolka_x(on: bool) -> VectorcraftApp { + let mut app = app_with(on); + app.run("shortcuts.set", json!({"id": "tool:eyedropper", "shortcut": "X", "force": true})).unwrap(); + app.run("shortcuts.set", json!({"id": "paint.swap", "hold": "X"})).unwrap(); + app +} + +/// The fill of the selected object, as `#rrggbb`. +fn fill(app: &VectorcraftApp) -> String { + let d = app.session.active().unwrap(); + let id = *d.selection.objects.first().unwrap(); + d.doc.node(id).unwrap().appearance.fill_paint().color().unwrap().to_hex() +} + +fn selected(app: &VectorcraftApp) -> usize { + app.session.active().unwrap().selection.objects.len() +} + +/// A quick press of X runs its tap at the release, and holding X runs the hold once at the delay, +/// also with no repeats; the repeats until the release run nothing more. +#[test] +fn a_tap_runs_the_key_and_a_hold_runs_the_hold_shortcut() { + let mut app = erolka_x(true); + let keys = Keyboard::new(); + keys.press(&mut app, 0.0, Key::X, "x"); + assert_eq!(app.session.tool_id(), "pen", "the press waits"); + keys.release(&mut app, 0.1, Key::X); + assert_eq!(app.session.tool_id(), "eyedropper", "the quick press chooses the Eyedropper"); + assert_eq!(fill(&app), "#ff0000", "and swaps nothing"); + + app.select_tool("pen"); + keys.press(&mut app, 1.0, Key::X, "x"); + keys.frame(&mut app, 1.2, vec![]); + assert_eq!(fill(&app), "#ff0000", "before the delay nothing runs"); + keys.frame(&mut app, 1.35, vec![]); + assert_eq!(fill(&app), "#0000ff", "at the delay the hold swaps fill and stroke"); + assert_eq!(app.session.tool_id(), "pen", "and chooses no tool"); + for t in [1.5, 1.6, 1.7] { + keys.press(&mut app, t, Key::X, "x"); + } + keys.release(&mut app, 1.8, Key::X); + assert_eq!(fill(&app), "#0000ff", "the repeats and the release swap nothing more"); + assert_eq!(app.session.tool_id(), "pen"); +} + +/// The delay is the Hold Shortcut Delay read at the press. +#[test] +fn the_hold_waits_for_the_hold_shortcut_delay() { + let mut app = erolka_x(true); + app.run("prefs.set", json!({"key": "keyHoldDelay", "value": 0.8})).unwrap(); + let keys = Keyboard::new(); + keys.press(&mut app, 0.0, Key::X, "x"); + app.run("prefs.set", json!({"key": "keyHoldDelay", "value": 0.2})).unwrap(); + keys.frame(&mut app, 0.5, vec![]); + assert_eq!(fill(&app), "#ff0000", "a later change does not move the wait"); + keys.frame(&mut app, 0.8, vec![]); + assert_eq!(fill(&app), "#0000ff"); +} + +/// erolka's `.`: a quick press keeps the key's own command (Apply Last Gradient) and keeps the +/// selection, and holding it deselects. +#[test] +fn the_period_key_taps_its_own_command_and_holds_to_deselect() { + let mut app = app_with(true); + app.run("shortcuts.set", json!({"id": "select.none", "hold": "."})).unwrap(); + let keys = Keyboard::new(); + keys.press(&mut app, 0.0, Key::Period, "."); + keys.release(&mut app, 0.1, Key::Period); + assert_eq!(selected(&app), 1, "the quick press keeps the selection"); + let d = app.session.active().unwrap(); + let id = *d.selection.objects.first().unwrap(); + let appearance = &d.doc.node(id).unwrap().appearance; + let gradient = |p: vectorcraft_color::Paint| matches!(p, vectorcraft_color::Paint::Gradient(_)); + assert!(gradient(appearance.fill_paint()) || gradient(appearance.stroke_paint()), "and applies the last gradient"); + // Solid paint again, so a hold that also ran the tap would show. + app.run("paint.setFill", json!({"color": "#ff0000"})).unwrap(); + app.run("paint.setStroke", json!({"color": "#0000ff"})).unwrap(); + keys.press(&mut app, 1.0, Key::Period, "."); + keys.frame(&mut app, 1.4, vec![]); + assert_eq!(selected(&app), 0, "the hold deselects"); + keys.release(&mut app, 1.5, Key::Period); + let appearance = &app.session.active().unwrap().doc.node(id).unwrap().appearance; + assert!(!gradient(appearance.fill_paint()) && !gradient(appearance.stroke_paint()), "and applies no gradient"); +} + +/// A hold on a letter alone does not catch the letter with Shift: Shift+X, held, does with Hold +/// Shortcuts on what it does with them off, and does not wait. +#[test] +fn a_hold_on_a_letter_leaves_the_letter_with_shift_alone() { + let mut results = vec![]; + for on in [false, true] { + let mut app = erolka_x(on); + let keys = Keyboard::new(); + keys.frame(&mut app, 0.0, press(Key::X, "X", Modifiers::SHIFT)); + assert!(app.hold_keys.pending.is_none(), "Shift+X does not wait (on {on})"); + let pressed = (fill(&app), app.session.tool_id().to_string()); + keys.frame(&mut app, 1.0, vec![]); + keys.frame(&mut app, 1.1, vec![release(Key::X)]); + results.push((pressed, fill(&app), app.session.tool_id().to_string())); + } + assert_eq!(results[0], results[1], "holding Shift+X does not run X's hold"); +} + +/// A letter the active tool takes itself (E with the Extend Path tool) does not wait, also with a +/// hold shortcut on it. +#[test] +fn a_letter_the_tool_takes_does_not_wait() { + let mut app = app_with(true); + app.run("shortcuts.set", json!({"id": "paint.swap", "hold": "E"})).unwrap(); + app.select_tool(vectorcraft_tools::addons::extend_path::ID); + assert_eq!(app.session.tool_id(), vectorcraft_tools::addons::extend_path::ID); + let keys = Keyboard::new(); + keys.press(&mut app, 0.0, Key::E, "e"); + assert!(app.hold_keys.pending.is_none(), "E stays the tool's"); + keys.frame(&mut app, 1.0, vec![]); + keys.release(&mut app, 1.1, Key::E); + assert_eq!(fill(&app), "#ff0000", "the hold does not run"); + assert_eq!(app.session.tool_id(), vectorcraft_tools::addons::extend_path::ID); +} + +/// An input method that starts composing while a key waits ends the wait without running anything. +#[test] +fn an_input_method_composition_ends_the_wait() { + let mut app = erolka_x(true); + let keys = Keyboard::new(); + keys.press(&mut app, 0.0, Key::X, "x"); + assert!(app.hold_keys.pending.is_some()); + keys.frame(&mut app, 0.1, vec![egui::Event::Ime(egui::ImeEvent::Preedit { text: "か".into(), active_range_chars: Some(1..1) })]); + assert!(app.hold_keys.pending.is_none(), "the composition ends the wait"); + keys.frame(&mut app, 1.0, vec![]); + keys.release(&mut app, 1.1, Key::X); + assert_eq!(app.session.tool_id(), "pen", "no tap ran"); + assert_eq!(fill(&app), "#ff0000", "and no hold"); +} + +/// A dialog opened, or Presentation Mode entered, while a key waits ends the wait without running +/// anything. +#[test] +fn a_dialog_or_presentation_mode_ends_the_wait() { + for what in ["dialog", "Presentation Mode"] { + let mut app = erolka_x(true); + let keys = Keyboard::new(); + keys.press(&mut app, 0.0, Key::X, "x"); + assert!(app.hold_keys.pending.is_some(), "{what}"); + if what == "dialog" { + app.ui.dialog = Some(crate::state::Dialog::new("preferences", json!({}))); + } else { + app.ui.screen_mode = 3; + } + keys.frame(&mut app, 0.1, vec![]); + assert!(app.hold_keys.pending.is_none(), "{what} ends the wait"); + app.ui.dialog = None; + app.ui.screen_mode = 0; + keys.frame(&mut app, 1.0, vec![]); + keys.release(&mut app, 1.1, Key::X); + assert_eq!(app.session.tool_id(), "pen", "{what}: no tap ran"); + assert_eq!(fill(&app), "#ff0000", "{what}: and no hold"); + } +} + +/// A new wait does not drop a wait left in another viewport unseen: that wait ends, and its key's +/// repeats stay held back in its viewport. +#[test] +fn a_wait_in_another_viewport_ends_when_a_new_one_starts() { + let mut app = erolka_x(true); + let other = egui::ViewportId::from_hash_of("another window"); + app.hold_keys.pending = Some(Pending { + entry: "paint.swap".into(), + chords: vec![], + key: Key::X, + physical: Some(Key::X), + mods: Modifiers::NONE, + since: 0.0, + delay: 0.35, + viewport: other, + }); + let keys = Keyboard::new(); + keys.press(&mut app, 0.1, Key::X, "x"); + assert!(app.hold_keys.pending.as_ref().is_some_and(|p| p.viewport == egui::ViewportId::ROOT), "the new press waits here"); + assert!(app.hold_keys.swallowed.iter().any(|s| s.viewport == other && s.key == Key::X), "the other window's key stays held back"); + assert_eq!(fill(&app), "#ff0000", "the other wait ran nothing"); +} + +/// With Hold Shortcuts off, a key with a hold shortcut runs on its press, as every key does, and +/// holding it runs nothing else. +#[test] +fn with_hold_shortcuts_off_every_key_runs_on_its_press() { + let mut app = erolka_x(false); + let keys = Keyboard::new(); + keys.press(&mut app, 0.0, Key::X, "x"); + assert_eq!(app.session.tool_id(), "eyedropper", "the press runs at once"); + keys.frame(&mut app, 1.0, vec![]); + keys.release(&mut app, 1.2, Key::X); + assert_eq!(fill(&app), "#ff0000", "the hold shortcut does not act"); + assert!(app.hold_keys.pending.is_none()); +} + +/// Turning Hold Shortcuts off while a key waits ends the wait without running anything. +#[test] +fn turning_hold_shortcuts_off_ends_the_wait() { + let mut app = erolka_x(true); + let keys = Keyboard::new(); + keys.press(&mut app, 0.0, Key::X, "x"); + assert!(app.hold_keys.pending.is_some()); + app.run("prefs.set", json!({"key": "holdShortcuts", "value": false})).unwrap(); + keys.frame(&mut app, 0.5, vec![]); + keys.release(&mut app, 0.6, Key::X); + assert!(app.hold_keys.pending.is_none()); + assert_eq!(fill(&app), "#ff0000", "no hold ran"); + assert_eq!(app.session.tool_id(), "pen", "and no tap"); +} + +/// A key without a hold shortcut runs in its press frame, and a waiting key pressed before it acts +/// first. +#[test] +fn another_key_ends_the_wait_and_runs_after_it() { + let mut app = erolka_x(true); + let keys = Keyboard::new(); + keys.press(&mut app, 0.0, Key::P, "p"); + assert_eq!(app.session.tool_id(), "pen", "P runs on its press"); + keys.release(&mut app, 0.05, Key::P); + keys.press(&mut app, 0.1, Key::X, "x"); + keys.press(&mut app, 0.2, Key::V, "v"); + assert_eq!(app.session.tool_id(), "selection", "X's tap (Eyedropper) ran, then V (Selection)"); + assert_eq!(fill(&app), "#ff0000"); + keys.release(&mut app, 0.3, Key::X); + assert_eq!(app.session.tool_id(), "selection", "the release of X runs nothing more"); +} + +/// Two keys pressed in one frame act in the order they went down. +#[test] +fn keys_in_one_frame_act_in_order() { + let mut app = erolka_x(true); + let keys = Keyboard::new(); + let mut events = press(Key::X, "x", Modifiers::NONE); + events.extend(press(Key::V, "v", Modifiers::NONE)); + keys.frame(&mut app, 0.0, events); + assert_eq!(app.session.tool_id(), "selection", "X's tap first, then V"); + let mut events = press(Key::V, "v", Modifiers::NONE); + events.extend(press(Key::X, "x", Modifiers::NONE)); + app.select_tool("pen"); + keys.frame(&mut app, 1.0, vec![release(Key::X), release(Key::V)]); + keys.frame(&mut app, 2.0, events); + keys.frame(&mut app, 2.1, vec![release(Key::X)]); + assert_eq!(app.session.tool_id(), "eyedropper", "V first, then X's tap at its release"); +} + +/// A press and its release in one frame are a tap, run in that frame. +#[test] +fn a_press_and_release_in_one_frame_is_a_tap() { + let mut app = erolka_x(true); + let keys = Keyboard::new(); + let mut events = press(Key::X, "x", Modifiers::NONE); + events.push(release(Key::X)); + keys.frame(&mut app, 0.0, events); + assert_eq!(app.session.tool_id(), "eyedropper"); + assert!(app.hold_keys.pending.is_none()); + keys.frame(&mut app, 5.0, vec![]); + assert_eq!(fill(&app), "#ff0000", "nothing waits after it"); +} + +/// Another key pressed after the delay has passed, before a frame ran the hold, runs the hold. +#[test] +fn an_overdue_wait_ended_by_another_key_runs_the_hold() { + let mut app = erolka_x(true); + let keys = Keyboard::new(); + keys.press(&mut app, 0.0, Key::X, "x"); + keys.press(&mut app, 0.5, Key::V, "v"); + assert_eq!(fill(&app), "#0000ff", "the hold ran"); + assert_eq!(app.session.tool_id(), "selection", "then V"); +} + +/// The window losing the keyboard ends the wait without running anything. +#[test] +fn losing_the_keyboard_ends_the_wait() { + let mut app = erolka_x(true); + let keys = Keyboard::new(); + keys.press(&mut app, 0.0, Key::X, "x"); + keys.frame_with_focus(&mut app, 0.1, vec![], false); + keys.frame(&mut app, 1.0, vec![]); + assert_eq!(app.session.tool_id(), "pen"); + assert_eq!(fill(&app), "#ff0000"); + assert!(app.hold_keys.pending.is_none()); +} + +/// Cmd, Ctrl or Alt pressed while a key waits ends the wait as a tap, before the chord runs. +#[test] +fn a_command_modifier_ends_the_wait_as_a_tap() { + let mut app = erolka_x(true); + let keys = Keyboard::new(); + keys.press(&mut app, 0.0, Key::X, "x"); + keys.frame(&mut app, 0.1, vec![egui::Event::ModifiersChanged(Modifiers::COMMAND)]); + assert_eq!(app.session.tool_id(), "eyedropper"); + keys.frame(&mut app, 1.0, vec![]); + assert_eq!(fill(&app), "#ff0000", "nothing waits after it"); +} + +/// A tool key with a hold shortcut runs the hold, and the tool is not chosen for the time the key +/// is held (`holdToolKeys`); a quick press chooses the tool for good. +#[test] +fn a_hold_shortcut_takes_a_tool_key_from_hold_tool_keys() { + let mut app = app_with(true); + assert!(app.session.prefs.hold_tool_keys); + app.run("shortcuts.set", json!({"id": "paint.swap", "hold": "S"})).unwrap(); + let keys = Keyboard::new(); + keys.press(&mut app, 0.0, Key::S, "s"); + keys.frame(&mut app, 0.4, vec![]); + assert_eq!(fill(&app), "#0000ff", "the hold runs"); + assert_eq!(app.session.tool_id(), "pen", "Scale is not chosen while S is held"); + keys.release(&mut app, 1.0, Key::S); + assert_eq!(app.session.tool_id(), "pen"); + keys.press(&mut app, 2.0, Key::S, "s"); + keys.release(&mut app, 2.1, Key::S); + assert_eq!(app.session.tool_id(), "scale", "a quick press chooses Scale"); + keys.frame(&mut app, 3.0, vec![]); + assert_eq!(app.session.tool_id(), "scale", "for good"); + assert!(app.held_tool.is_empty()); +} + +/// A tool key without a hold shortcut still chooses its tool while held when another key has one. +#[test] +fn other_tool_keys_keep_hold_tool_keys() { + let mut app = erolka_x(true); + let keys = Keyboard::new(); + keys.press(&mut app, 0.0, Key::S, "s"); + assert_eq!(app.session.tool_id(), "scale"); + keys.frame(&mut app, 1.0, vec![]); + keys.release(&mut app, 1.1, Key::S); + assert_eq!(app.session.tool_id(), "pen", "the Pen comes back"); +} + +/// A hold on Shift and a digit recorded in the dialog (Shift+1) holds when the press types `!`. +#[test] +fn a_shifted_digit_holds_when_it_types_its_symbol() { + let mut app = app_with(true); + app.run("shortcuts.set", json!({"id": "paint.swap", "hold": "Shift+1"})).unwrap(); + let keys = Keyboard::new(); + keys.frame(&mut app, 0.0, press(Key::Num1, "!", Modifiers::SHIFT)); + keys.frame(&mut app, 0.4, vec![]); + assert_eq!(fill(&app), "#0000ff"); +} + +/// A quick press of a shifted key with a hold shortcut runs what the key runs without one: a +/// shortcut on Shift+. (typing `>`) runs, and Shift+1 (typing `!`) runs what `!` runs. +#[test] +fn a_quick_press_of_a_shifted_key_runs_what_it_runs_without_a_hold() { + for (key, text, chord) in [(Key::Period, ">", "Shift+."), (Key::Num1, "!", "Shift+1")] { + let mut app = app_with(true); + app.run("shortcuts.set", json!({"id": "tool:eyedropper", "shortcut": chord, "force": true})).unwrap(); + let keys = Keyboard::new(); + keys.frame(&mut app, 0.0, press(key, text, Modifiers::SHIFT)); + keys.frame(&mut app, 0.05, vec![release(key)]); + let without = app.session.tool_id().to_string(); + app.select_tool("pen"); + app.run("shortcuts.set", json!({"id": "paint.swap", "hold": chord})).unwrap(); + keys.frame(&mut app, 1.0, press(key, text, Modifiers::SHIFT)); + assert_eq!(app.session.tool_id(), "pen", "{chord} waits"); + keys.frame(&mut app, 1.05, vec![release(key)]); + assert_eq!(app.session.tool_id(), without, "a quick press of {chord}"); + assert_eq!(fill(&app), "#ff0000"); + } +} + +/// The Shift+. shortcut runs on its press without a hold shortcut, and at the release of a quick +/// press with one. +#[test] +fn a_quick_press_of_shift_period_runs_its_shortcut() { + let mut app = app_with(true); + app.run("shortcuts.set", json!({"id": "tool:eyedropper", "shortcut": "Shift+.", "force": true})).unwrap(); + app.run("shortcuts.set", json!({"id": "paint.swap", "hold": "Shift+."})).unwrap(); + let keys = Keyboard::new(); + keys.frame(&mut app, 0.0, press(Key::Period, ">", Modifiers::SHIFT)); + keys.frame(&mut app, 0.05, vec![release(Key::Period)]); + assert_eq!(app.session.tool_id(), "eyedropper"); +} + +/// A text with no key press that typed it does not wait: it has no key to let go. +#[test] +fn a_text_without_its_key_press_does_not_wait() { + let mut app = erolka_x(true); + let keys = Keyboard::new(); + keys.frame(&mut app, 0.0, vec![egui::Event::Text("x".into())]); + assert!(app.hold_keys.pending.is_none()); + assert_eq!(app.session.tool_id(), "eyedropper", "it runs as a single-key shortcut, as before"); +} + +/// A hold whose command opens a dialog holds back the key's repeats from it. +#[test] +fn a_hold_that_opens_a_dialog_keeps_the_repeats_from_it() { + let mut app = app_with(true); + app.run("shortcuts.set", json!({"id": "edit.preferences", "hold": "K"})).unwrap(); + let keys = Keyboard::new(); + keys.press(&mut app, 0.0, Key::K, "k"); + keys.frame(&mut app, 0.4, vec![]); + assert!(app.ui.dialog.is_some(), "the hold opened Preferences"); + let opening = keys.ctx.data(|m| m.get_temp::(super::super::opening_key_id(&keys.ctx))); + assert_eq!(opening, Some(Key::K), "K is the key that opened it"); + keys.press(&mut app, 0.5, Key::K, "k"); + assert!(app.hold_keys.swallowed.iter().any(|s| s.key == Key::K), "K's repeats are held back until it is let go"); + // A repeat in the same frame as the release is held back too. + let mut events = press(Key::K, "k", Modifiers::NONE); + events.push(release(Key::K)); + let left = keys.frame_left(&mut app, 0.6, events); + assert!(!left.iter().any(|e| matches!(e, egui::Event::Text(_) | egui::Event::Key { pressed: true, .. })), "{left:?}"); + assert!(app.hold_keys.swallowed.is_empty()); +} + +/// A key that ends a wait whose tap opens a dialog does not reach the dialog: Enter does not +/// confirm it. +#[test] +fn the_key_that_ends_a_wait_does_not_reach_the_dialog_it_opened() { + let mut app = app_with(true); + app.run("shortcuts.set", json!({"id": "edit.preferences", "shortcut": "K", "force": true})).unwrap(); + app.run("shortcuts.set", json!({"id": "paint.swap", "hold": "K"})).unwrap(); + let keys = Keyboard::new(); + keys.press(&mut app, 0.0, Key::K, "k"); + let enter = egui::Event::Key { key: Key::Enter, physical_key: Some(Key::Enter), pressed: true, repeat: false, modifiers: Modifiers::NONE }; + let left = keys.frame_left(&mut app, 0.1, vec![enter]); + assert!(app.ui.dialog.is_some(), "the tap opened Preferences"); + assert!(!left.iter().any(|e| matches!(e, egui::Event::Key { key: Key::Enter, .. })), "{left:?}"); + assert_eq!(fill(&app), "#ff0000"); +} + +/// On the web build a press's text comes before it: the text of the key that ends such a wait +/// does not reach the dialog either. +#[test] +fn the_text_before_the_key_that_ends_a_wait_does_not_reach_the_dialog() { + let mut app = app_with(true); + app.run("shortcuts.set", json!({"id": "edit.preferences", "shortcut": "K", "force": true})).unwrap(); + app.run("shortcuts.set", json!({"id": "paint.swap", "hold": "K"})).unwrap(); + let keys = Keyboard::new(); + keys.press(&mut app, 0.0, Key::K, "k"); + let m = egui::Event::Key { key: Key::M, physical_key: Some(Key::M), pressed: true, repeat: false, modifiers: Modifiers::NONE }; + let left = keys.frame_left(&mut app, 0.1, vec![egui::Event::Text("m".into()), m]); + assert!(app.ui.dialog.is_some(), "the tap opened Preferences"); + assert!(!left.iter().any(|e| matches!(e, egui::Event::Text(_) | egui::Event::Key { pressed: true, .. })), "{left:?}"); +} diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index 2fbe54d633..dc83db59bc 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -670,6 +670,12 @@ pub struct UiState { /// stored in the form every earlier version reads. #[serde(default, with = "crate::keymap::stored")] pub shortcut_overrides: craft_keymap::Overrides, + /// Hold shortcuts: command id, `tool:` or `panel:` → a character key, alone or with + /// Shift ("X", "Shift+X", "."). Holding the key for the Hold Shortcut Delay runs the entry; a + /// quick press runs the key's own shortcut when it is let go. Kept apart from + /// `shortcut_overrides`, so earlier versions read the settings without them. + #[serde(default, skip_serializing_if = "std::collections::BTreeMap::is_empty")] + pub shortcut_holds: std::collections::BTreeMap, /// Name of the shortcut set (preset or "Custom"). #[serde(default = "default_shortcut_set", deserialize_with = "crate::shortcut_editor::deserialize_set_name")] pub shortcut_set: String, @@ -1221,6 +1227,7 @@ impl Default for UiState { action_playback: Default::default(), action_playing: None, shortcut_overrides: Default::default(), + shortcut_holds: Default::default(), shortcut_set: default_shortcut_set(), workspace: default_workspace(), touch_workspace_restore: None, diff --git a/docs/mcp.md b/docs/mcp.md index e623b86cac..d67835d549 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -6330,6 +6330,33 @@ page describes saving the list from the Keyboard Shortcuts dialog as a text file {"name":"run_command","arguments":{"command":"shortcuts.exportText","params":{"path":"/Users/me/Shortcuts.txt"}}} ``` +A tool or command can also have a hold shortcut: a key that types a character (a letter, a digit or a punctuation +key), alone or with Shift. Space and the backtick key cannot be hold shortcuts, and neither can a key with Cmd, Ctrl or +Alt. Hold shortcuts act only while the preference `holdShortcuts` is on; it is off by default, and Edit › Keyboard +Shortcuts shows it as the Hold Shortcuts checkbox, with a ? button that explains it. While it is off, the dialog shows +no Hold column and every key runs on its press. While it is on, the dialog shows a Hold column and the Hold Shortcut +Delay (`keyHoldDelay`, 0.2 to 1.0 s, 0.35 s by default; VectorCraft's own values). Preferences › General › Options +lists both settings too, with Hold Shortcut Delay dimmed while Hold Shortcuts is off. A key with a hold shortcut then +waits when it goes down: held for the delay, it runs its hold shortcut once and its repeats are ignored until it is let +go; let go sooner, it runs what the key runs without a hold shortcut, at the release. Another key pressed while one +waits, or Cmd, Ctrl or Alt pressed then, ends the wait first, so keys act in the order they went down. The window losing +the keyboard, a dialog, a text field, Presentation Mode or an input method composition ends the wait and runs nothing. +Keys without a hold shortcut run on their press as before, and so does a letter with Shift when only the letter alone +has a hold shortcut, or a key the active tool uses itself (E with the Extend Path tool). + +`shortcuts.set {id, hold}` sets a hold shortcut, and `hold: ""` or `null` removes it; `hold` alone leaves the entry's +shortcut as it is, and a key that another entry already holds is refused unless `force` is true. Hold shortcuts are +kept apart from shortcuts: Use Default, Clear and `shortcut: null` leave them, and `overridden` in `shortcuts.list` is +about the shortcut only. `shortcuts.list` rows give the hold shortcut as `hold`, `shortcuts.conflicts` lists a key two +entries hold as `"Hold X"`, and Reset to Defaults and a preset remove every hold shortcut. `shortcuts.export` writes +them as a `holds` object (entry id to key) when there are any, and `shortcuts.import` reads it; a file without `holds` +has none, and a `holds` value that is not a usable hold shortcut fails the import, which then changes nothing. +`shortcuts.exportText` adds a third `Hold X` column to a row with a hold shortcut while `holdShortcuts` is on. + +```json +{"name":"run_command","arguments":{"command":"shortcuts.set","params":{"id":"paint.swap","hold":"X"}}} +``` + The desktop app adds its active artboard, the one the Artboards panel highlights, to the `object.align`, `object.distribute`, `object.distributeSpacing` and `select.allOnArtboard` calls it runs without `artboard`, as it does for `edit.pasteInPlace`, `edit.pasteInFront` and `edit.pasteInBack` (while the Artboard tool has several artboards @@ -6556,8 +6583,9 @@ interface and not the art: a zoom shows the art at the same size at every UI Sca preference `holdToolKeys` also needs the desktop app. It is on by default: a single-key tool shortcut held for 0.25 s or more, or held while its tool is used, chooses the tool until the key is let go and then returns to the tool active before, after any drag in progress; a quicker press chooses the tool for good. With it off, every press and every key -repeat chooses the tool. The canvas preference `boundingBoxWhileMovingAndDrawing` (off by default) also needs the -desktop app: on, with View › Show Bounding Box, the bounding box and its handles stay visible while a drag moves the +repeat chooses the tool. While `holdShortcuts` is on, a tool key that also has a hold shortcut runs the hold shortcut +when held, and a quick press chooses its tool for good. The canvas preference `boundingBoxWhileMovingAndDrawing` (off +by default) also needs the desktop app: on, with View › Show Bounding Box, the bounding box and its handles stay visible while a drag moves the selection, and the Rectangle, Rounded Rectangle, Ellipse, Polygon and Star tools draw the box around the shape being drawn; off, the box hides during both, except that a Selection tool move with `realTimeDrawing` off still moves the box. `highlightAlternateGlyphs` (off by default: on, the canvas paints a pink cell behind glyphs OpenType features diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 10d476361a..566c19f635 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1233,6 +1233,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur A Space+Shift drag rotates the view whatever the tool, as a Rotate View tool drag does, and Shift does not round the angle to 15°. While the Type tool edits text, Space types a space: held, it does not show the hand, pan or rotate the view, and Cmd+Space still zooms ([the help page](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html) lists the Spacebar as the Hand tool when not in text-edit mode). Test: `canvas::tests::space_types_a_space_while_editing_text_and_does_not_pan`. As VectorCraft's own rule, a zoom marquee that Cmd+Space starts while the Type tool edits text keeps the marquee's Space rules after Cmd is let go: Space held since the press sizes it, Space pressed again moves it ([the help page](https://helpx.adobe.com/illustrator/using/viewing-artwork.html) describes holding the spacebar to move the marquee), and that Space types no space, nor does it during an animated zoom drag. With no zoom drag, Space types a space. Test: `canvas::tests::space_moves_a_text_edit_zoom_marquee_after_cmd_is_let_go`. + - **Hold shortcuts:** Edit › Keyboard Shortcuts › Hold Shortcuts (off by default, `holdShortcuts`) shows a Hold column, where a tool or command gets a letter, digit or punctuation key, alone or with Shift. Holding that key for the Hold Shortcut Delay (`keyHoldDelay`, 0.35 s, 0.2 to 1.0 s) runs it once; a quicker press runs what the key runs without one, at the release (`shortcuts.set {id, hold}`). On a tool key, the hold shortcut takes precedence over Hold a Tool Shortcut to Use the Tool Temporarily. This is VectorCraft's own feature and its own delay. Tests `shortcuts::hold_keys::tests` and `shortcut_editor::tests::{a_hold_shortcut_is_kept_apart_from_the_shortcut, hold_shortcuts_refuse_keys_that_cannot_wait, the_hold_shortcuts_checkbox_shows_the_hold_column}`. - **Swatches panel clicks:** Ctrl/Cmd-clicking New Swatch makes a spot color, and Ctrl/Cmd+Shift-clicking it makes a global process color. - **Panel drag and drop:** art dragged off the canvas onto the Symbols panel becomes a symbol, art dragged onto the Swatches panel becomes a pattern swatch, and art dropped on the Brushes panel opens New Brush for that art; a symbol dragged onto the canvas places an instance where it is dropped, and a brush dragged onto a path is applied to it. New Brush asks for the type of brush first, as the [Brushes](https://web.archive.org/web/20241230205225/https://helpx.adobe.com/illustrator/using/brushes.html) page (archived copy) describes. The Brushes panel's New Brush button, its menu's New Brush… and art dropped on the panel open the New Brush dialog, where Scatter Brush, Art Brush and Pattern Brush need selected or dropped art. OK opens that type's Brush Options for the new brush, and their OK makes the brush with the name and options set; Cancel in either dialog adds no brush (`ui.newBrush`). The menu's New Calligraphic Brush, New Bristle Brush and New Art, Scatter and Pattern Brush from Selection items still make a brush at once. From 7f3656a58d7c30552251432b5ce599f6fd2d4346 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 09:19:53 -0800 Subject: [PATCH 02/17] Fix build after merging main category_fields now returns the rows that carry a description, so the Hold Shortcut Delay test's UI closure discards the value, as the other prefs_dialog tests do. --- crates/ui-egui/src/prefs_dialog/tests.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/prefs_dialog/tests.rs b/crates/ui-egui/src/prefs_dialog/tests.rs index 019468f4ae..973a0111f7 100644 --- a/crates/ui-egui/src/prefs_dialog/tests.rs +++ b/crates/ui-egui/src/prefs_dialog/tests.rs @@ -1117,7 +1117,9 @@ fn hold_shortcut_delay_dims_without_hold_shortcuts() { events, ..Default::default() }; - let mut out = ctx.run_ui(raw, |ui| category_fields(ui, &mut a, d, "General")); + let mut out = ctx.run_ui(raw, |ui| { + category_fields(ui, &mut a, d, "General"); + }); out.textures_delta.clear(); let label = out.shapes.iter().find_map(|c| text(&c.shape, &|t| t.starts_with("Hold Shortcut Delay"))); let field = out.shapes.iter().find_map(|c| text(&c.shape, &|t| t.starts_with("0.35"))); From d8529f111d0b9b0115b2c35a89bb1bbc33cb334c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 10:55:29 -0800 Subject: [PATCH 03/17] Shortcuts: hold keys keep their order in a frame, and the sheet and CSV list hold shortcuts - When a key with a hold shortcut is pressed and its wait ends in the same frame, the single-key shortcuts typed before it in that frame run first, so the keys act in the order they went down. - The repeats of a key in the frame that starts its wait, and the text they type, are dropped like its later repeats. - Import Shortcut Set started from the VectorCraft defaults clears the working hold shortcuts; Add to the Current Shortcuts keeps them. - Export Text's shortcut sheet and CSV file list a row's hold shortcut after its shortcuts while Hold Shortcuts is on, as the text file does. --- crates/ui-egui/src/dialogs/shortcut_import.rs | 4 + .../src/dialogs/tests_shortcut_import.rs | 18 ++++ crates/ui-egui/src/shortcut_editor.rs | 53 +++++++-- crates/ui-egui/src/shortcuts/hold_keys.rs | 86 +++++++++++++-- .../ui-egui/src/shortcuts/hold_keys/tests.rs | 102 ++++++++++++++++-- 5 files changed, 241 insertions(+), 22 deletions(-) diff --git a/crates/ui-egui/src/dialogs/shortcut_import.rs b/crates/ui-egui/src/dialogs/shortcut_import.rs index 0516695233..e3ca87762a 100644 --- a/crates/ui-egui/src/dialogs/shortcut_import.rs +++ b/crates/ui-egui/src/dialogs/shortcut_import.rs @@ -518,6 +518,10 @@ pub fn confirm(app: &mut VectorcraftApp, d: &Dialog) -> Result { } if let Some(k) = app.ui.dialog.as_mut() { k.fields.insert("overrides".into(), crate::keymap::stored::to_value(&shortcut_editor::saved_overrides(km.overrides(), &ov))); + // VectorCraft's defaults have no hold shortcuts; Add to the Current Shortcuts keeps them. + if !current { + k.fields.insert("holds".into(), json!({})); + } k.fields.insert("set".into(), json!(set)); k.fields.insert("__message".into(), json!(tl!("Imported. Press OK to keep the imported set."))); } diff --git a/crates/ui-egui/src/dialogs/tests_shortcut_import.rs b/crates/ui-egui/src/dialogs/tests_shortcut_import.rs index 066f7f4682..a4f8ba9d4b 100644 --- a/crates/ui-egui/src/dialogs/tests_shortcut_import.rs +++ b/crates/ui-egui/src/dialogs/tests_shortcut_import.rs @@ -234,6 +234,24 @@ fn cancel_and_apply_go_back_to_keyboard_shortcuts() { assert_eq!((app.ui.shortcut_set.as_str(), app.ui.shortcut_overrides.len()), ("Acme Keys", 3)); } +/// Started from VectorCraft's defaults, an import leaves no hold shortcut in the working set; added +/// to the current shortcuts, it keeps them. OK keeps what the working set shows. +#[test] +fn an_import_from_the_defaults_clears_the_hold_shortcuts() { + let mut app = app(); + earlier_answers(&mut app); + for (start, kept) in [("defaults", json!({})), ("current", json!({"paint.swap": "X"}))] { + app.ui.shortcut_holds = [("paint.swap".to_string(), "X".to_string())].into(); + shortcut_editor::open(&mut app); + super::shortcut_import::open(&mut app, "/sets/Acme Keys.kys", SET.as_bytes()).unwrap(); + set(&mut app, "start", json!(start)); + confirm(&mut app).unwrap(); + assert_eq!(dialog(&app).fields["holds"], kept, "{start}"); + confirm(&mut app).unwrap(); + assert_eq!(json!(app.ui.shortcut_holds), kept, "{start}: OK keeps it"); + } +} + /// A document's Missing Fonts dialog that Keyboard Shortcuts replaced waits while Cancel goes back /// from Import Shortcut Set to Keyboard Shortcuts, and opens again once Keyboard Shortcuts closes. #[test] diff --git a/crates/ui-egui/src/shortcut_editor.rs b/crates/ui-egui/src/shortcut_editor.rs index 8ba8bda125..a1cb43d874 100644 --- a/crates/ui-egui/src/shortcut_editor.rs +++ b/crates/ui-egui/src/shortcut_editor.rs @@ -1375,8 +1375,9 @@ const MENU_COMMANDS: &str = "Menu Commands"; /// Export Text's rows in sections, for the shortcut sheet and the CSV file: Tools, then one section /// per top-level menu in the order the dialog first lists a command of it, with the names and /// shortcuts as the dialog shows them, each name without its top-level menu. Every row the dialog -/// lists is there, with an empty shortcut when it has none. -pub fn export_sections(overrides: &Overrides) -> Vec { +/// lists is there, with an empty shortcut when it has none. A row with a hold shortcut in `holds` +/// ends its shortcuts with `Hold X`, joined as the dialog joins them. +pub fn export_sections(overrides: &Overrides, holds: &Holds) -> Vec { use crate::shortcut_sheet::{Row, Section}; let snapshot = snapshot(); let km = crate::keymap::keymap_in(&snapshot, overrides); @@ -1385,6 +1386,11 @@ pub fn export_sections(overrides: &Overrides) -> Vec = vec![]; for e in snapshot.entries.iter().filter(|e| listed(km.overrides(), e)) { let shortcut = dialog_shortcuts_with(&km, &e.key, backtick.as_deref()).unwrap_or_default(); + let shortcut = match hold_of(holds, &e.key) { + Some(h) if shortcut.is_empty() => format!("{} {}", tl!("Hold"), menus::pretty_shortcut(&h)), + Some(h) => format!("{shortcut} · {} {}", tl!("Hold"), menus::pretty_shortcut(&h)), + None => shortcut, + }; if e.is_tool { tools.rows.push(Row { name: shown_name(e), shortcut }); continue; @@ -1415,9 +1421,9 @@ fn export_text_file( TextFormat::Text => Ok(export_text_with(set, overrides, holds).into_bytes()), TextFormat::Sheet => { let title = format!("{} · {}", tl!("Keyboard Shortcuts"), shown_set_name(set)); - crate::shortcut_sheet::sheet_pdf(&title, &export_sections(overrides), page) + crate::shortcut_sheet::sheet_pdf(&title, &export_sections(overrides, holds), page) } - TextFormat::Csv => Ok(crate::shortcut_sheet::csv(&export_sections(overrides), ["Group", "Command", "Shortcut"]).into_bytes()), + TextFormat::Csv => Ok(crate::shortcut_sheet::csv(&export_sections(overrides, holds), ["Group", "Command", "Shortcut"]).into_bytes()), } } @@ -2712,7 +2718,7 @@ mod tests { tops.push(top); } } - (export_sections(&ov), listed.len(), tops) + (export_sections(&ov, &Holds::new()), listed.len(), tops) }); let titles: Vec<&str> = sections.iter().map(|s| s.title.as_str()).collect(); assert_eq!(titles[0], "Tools"); @@ -2787,7 +2793,7 @@ mod tests { Ok(()) })); app.run("shortcuts.exportText", json!({"path": "/a/list.csv", "format": "csv"})).unwrap(); - (returned, written.borrow().clone(), export_sections(&app.ui.shortcut_overrides)) + (returned, written.borrow().clone(), export_sections(&app.ui.shortcut_overrides, &Holds::new())) }); let [(path, bytes)] = files.as_slice() else { panic!("{} files", files.len()) }; assert_eq!(path, "/a/list.csv"); @@ -3637,6 +3643,41 @@ mod tests { assert_eq!(on.split('\t').nth(2), Some(format!("Hold {}", menus::pretty_shortcut("X")).as_str()), "{on}"); } + /// Export Text…'s shortcut sheet and CSV file also list a hold shortcut while Hold Shortcuts is + /// on, after the row's shortcuts. + #[test] + fn the_sheet_and_csv_list_hold_shortcuts_while_they_act() { + type Files = std::rc::Rc>>>; + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + let written: Files = Default::default(); + let w = written.clone(); + app.services.write = Some(Box::new(move |_: &str, b: &[u8]| { + w.borrow_mut().push(b.to_vec()); + Ok(()) + })); + app.run("shortcuts.set", json!({"id": "paint.swap", "hold": "X"})).unwrap(); + let hold = format!("Hold {}", menus::pretty_shortcut("X")); + let sections = with_steady_plugins(|| { + written.borrow_mut().clear(); + for on in [false, false, true] { + app.run("prefs.set", json!({"key": "holdShortcuts", "value": on})).unwrap(); + app.run("shortcuts.exportText", json!({"path": "/a.csv", "format": "csv"})).unwrap(); + app.run("shortcuts.exportText", json!({"path": "/a.pdf", "format": "sheet"})).unwrap(); + } + app.run("prefs.set", json!({"key": "holdShortcuts", "value": false})).unwrap(); + export_sections(&app.ui.shortcut_overrides, &app.ui.shortcut_holds) + }); + let files = written.borrow(); + let [csv_off, sheet_off, _, sheet_off_again, csv_on, sheet_on] = files.as_slice() else { panic!("{} files", files.len()) }; + let swap = sections.iter().flat_map(|s| &s.rows).filter(|r| r.shortcut.ends_with(&hold)).collect::>(); + assert_eq!(swap.len(), 1, "one row has the hold: {swap:?}"); + let (csv_off, csv_on) = (String::from_utf8_lossy(csv_off), String::from_utf8_lossy(csv_on)); + assert!(!csv_off.contains(&hold), "off, the CSV file lists no hold"); + assert!(csv_on.contains(&swap[0].shortcut), "on, the CSV file lists it: {}", swap[0].shortcut); + assert_eq!(sheet_off, sheet_off_again, "the sheet is the same each time"); + assert_ne!(sheet_off, sheet_on, "on, the sheet lists the hold"); + } + /// The text the Keyboard Shortcuts dialog draws in its second frame. fn dialog_texts(app: &mut VectorcraftApp) -> Vec { let ctx = egui::Context::default(); diff --git a/crates/ui-egui/src/shortcuts/hold_keys.rs b/crates/ui-egui/src/shortcuts/hold_keys.rs index eb7c92ab04..b494050bd2 100644 --- a/crates/ui-egui/src/shortcuts/hold_keys.rs +++ b/crates/ui-egui/src/shortcuts/hold_keys.rs @@ -208,13 +208,59 @@ fn tool_takes(app: &mut VectorcraftApp, key: Key, text: &str) -> bool { tool_key.is_some_and(|k| app.session.tool_claims_key(k, view)) } +/// Runs the single-key shortcuts of the texts typed before the event at `start` that no wait took, +/// in order, as the frame's shortcuts would run them, and takes them and their presses from the +/// frame. A text typed with Cmd, Ctrl or Alt, by a key the active tool takes, or with no shortcut, +/// is left to the frame. True when one opened a dialog or the palette. +fn run_typed_before( + app: &mut VectorcraftApp, + ctx: &egui::Context, + events: &[egui::Event], + typed_by: &[Option], + start: usize, + taken: &mut Vec, +) -> bool { + for (k, e) in events.iter().enumerate().take(start) { + let egui::Event::Text(text) = e else { continue }; + let by = typed_by.get(k).copied().flatten(); + if taken.contains(&k) || by.is_some_and(|b| taken.contains(&b)) { + continue; + } + let (key, physical, repeat, m) = match by.and_then(|b| events.get(b)) { + Some(egui::Event::Key { key, physical_key, repeat, modifiers, .. }) => (Some(*key), *physical_key, *repeat, *modifiers), + _ => (None, None, false, ctx.input(|i| i.modifiers)), + }; + if m.command || m.ctrl || m.alt || m.mac_cmd || key.is_some_and(|key| tool_takes(app, key, text)) { + continue; + } + let typed = super::latin(text, physical); + let chords = match key { + Some(key) => tap_chords(&typed, key, m), + None => super::text_chords(&typed, m, None), + }; + // A key with no shortcut stays in the frame for what reads it later (Space for the canvas). + let keymap = crate::shortcut_editor::current(); + if !chords.iter().any(|c| crate::keymap::lookup(&keymap.keymap, c).is_some()) { + continue; + } + taken.push(k); + taken.extend(by); + if super::run_single_key(app, ctx, &chords, key, repeat) { + return true; + } + } + false +} + /// Before the frame's shortcuts run: goes through the frame's events in order. A release of the /// waiting key ends the wait (the hold when the delay has passed, otherwise the tap); a press of /// another key, or a change of Cmd, Ctrl or Alt, ends it first, so the keys act in the order they /// went down; and a new press of a key with a hold shortcut starts a wait, taking the press and -/// its text from the frame. Then a wait whose delay has passed with the key down runs the hold -/// shortcut. True when a result opened a dialog or the palette: the rest of the frame's keys are -/// dropped and no other shortcut runs. +/// its text from the frame, with the key's repeats that follow in the frame and their text. When a +/// wait that started in this frame also ends in it, the keys typed before its key run first +/// ([`run_typed_before`]), so they act in the order they went down. Then a wait +/// whose delay has passed with the key down runs the hold shortcut. True when a result opened a +/// dialog or the palette: the rest of the frame's keys are dropped and no other shortcut runs. pub(super) fn intake(app: &mut VectorcraftApp, ctx: &egui::Context) -> bool { // Off (Keyboard Shortcuts › Hold Shortcuts), every key runs on its press. if !app.session.prefs.hold_shortcuts || blocked(app, ctx) { @@ -226,6 +272,9 @@ pub(super) fn intake(app: &mut VectorcraftApp, ctx: &egui::Context) -> bool { let text_of = |k: usize| typed_by.iter().position(|by| *by == Some(k)).and_then(|j| events.get(j).map(|e| (j, e))); let mut taken: Vec = vec![]; let mut stop_at = None; + // The press of a wait that started in this frame: when the wait also ends in this frame, the + // keys typed before it run first. + let mut started: Option = None; for (j, e) in events.iter().enumerate() { if let Some(p) = app.hold_keys.pending.as_ref().filter(|p| p.viewport == viewport) { let overdue = now - p.since >= p.delay; @@ -248,11 +297,20 @@ pub(super) fn intake(app: &mut VectorcraftApp, ctx: &egui::Context) -> bool { _ => None, } }; - if let Some((hold, down)) = ended - && settle(app, ctx, hold, down) - { - stop_at = Some(j); - break; + if let Some((hold, down)) = ended { + // A key typed before it that opened a dialog or the palette ends the wait without + // running it. + if let Some(start) = started.take() + && run_typed_before(app, ctx, &events, &typed_by, start, &mut taken) + { + cancel(app, ctx); + stop_at = Some(j); + break; + } + if settle(app, ctx, hold, down) { + stop_at = Some(j); + break; + } } } let egui::Event::Key { key, physical_key, pressed: true, repeat: false, modifiers: m } = e else { continue }; @@ -271,7 +329,19 @@ pub(super) fn intake(app: &mut VectorcraftApp, ctx: &egui::Context) -> bool { if tool_takes(app, *key, text) { continue; } + started = Some(j); taken.extend([j, t]); + // The key's repeats in this frame, and the text they type, stay out of the frame too. + for (r, later) in events.iter().enumerate().skip(j + 1) { + if releases(later, *key, *physical_key) { + break; + } + if matches!(later, egui::Event::Key { key: k, physical_key: p, pressed: true, repeat: true, .. } if same_key(*k, *p, *key, *physical_key)) + { + taken.push(r); + taken.extend(text_of(r).map(|(rt, _)| rt)); + } + } // A wait left in another viewport ends without running: that window lost the keyboard to // this one. Its key's repeats stay held back there until it is let go. if let Some(old) = app.hold_keys.pending.take_if(|p| p.viewport != viewport) { diff --git a/crates/ui-egui/src/shortcuts/hold_keys/tests.rs b/crates/ui-egui/src/shortcuts/hold_keys/tests.rs index be7765f8f3..4e745510fe 100644 --- a/crates/ui-egui/src/shortcuts/hold_keys/tests.rs +++ b/crates/ui-egui/src/shortcuts/hold_keys/tests.rs @@ -307,22 +307,108 @@ fn another_key_ends_the_wait_and_runs_after_it() { assert_eq!(app.session.tool_id(), "selection", "the release of X runs nothing more"); } -/// Two keys pressed in one frame act in the order they went down. +/// The labels of the document's undo steps after the first `from`. +fn steps(app: &VectorcraftApp, from: usize) -> Vec { + app.session.doc().unwrap().history.undo.iter().skip(from).map(|e| e.label.clone()).collect() +} + +/// The label of the undo step `command` records on [`app_with`]'s document. +fn label(command: &str) -> String { + let mut app = app_with(true); + let n = steps(&app, 0).len(); + app.run(command, json!({})).unwrap(); + steps(&app, n).pop().unwrap() +} + +/// A quick press of X swaps fill and stroke, and holding X deselects; D sets the default fill and +/// stroke, as by default. +fn swap_on_x() -> VectorcraftApp { + let mut app = app_with(true); + assert_eq!(crate::shortcut_editor::default_of("paint.default"), Some("D")); + app.run("shortcuts.set", json!({"id": "paint.swap", "shortcut": "X", "force": true})).unwrap(); + app.run("shortcuts.set", json!({"id": "select.none", "hold": "X"})).unwrap(); + app +} + +/// Two keys pressed in one frame act in the order they went down, each once. #[test] fn keys_in_one_frame_act_in_order() { - let mut app = erolka_x(true); + let (swap, default) = (label("paint.swap"), label("paint.default")); + assert_ne!(swap, default); + let mut app = swap_on_x(); let keys = Keyboard::new(); + let n = steps(&app, 0).len(); let mut events = press(Key::X, "x", Modifiers::NONE); - events.extend(press(Key::V, "v", Modifiers::NONE)); + events.extend(press(Key::D, "d", Modifiers::NONE)); keys.frame(&mut app, 0.0, events); - assert_eq!(app.session.tool_id(), "selection", "X's tap first, then V"); - let mut events = press(Key::V, "v", Modifiers::NONE); + assert_eq!(steps(&app, n), [swap.clone(), default.clone()], "X's tap first, then D"); + keys.frame(&mut app, 1.0, vec![release(Key::X), release(Key::D)]); + // Paint that D changes again. + app.run("paint.setFill", json!({"color": "#ff0000"})).unwrap(); + let n = steps(&app, 0).len(); + let mut events = press(Key::D, "d", Modifiers::NONE); events.extend(press(Key::X, "x", Modifiers::NONE)); - app.select_tool("pen"); - keys.frame(&mut app, 1.0, vec![release(Key::X), release(Key::V)]); keys.frame(&mut app, 2.0, events); keys.frame(&mut app, 2.1, vec![release(Key::X)]); - assert_eq!(app.session.tool_id(), "eyedropper", "V first, then X's tap at its release"); + assert_eq!(steps(&app, n), [default, swap], "D first, then X's tap at its release"); + assert_eq!(selected(&app), 1, "and no hold"); +} + +/// A wait that starts in a frame after another key, and that a release or another key ends in the +/// same frame, runs its tap after that key. +#[test] +fn a_wait_ended_in_its_frame_runs_after_the_keys_before_it() { + let (swap, default) = (label("paint.swap"), label("paint.default")); + let mut app = swap_on_x(); + let keys = Keyboard::new(); + let n = steps(&app, 0).len(); + let mut events = press(Key::D, "d", Modifiers::NONE); + events.extend(press(Key::X, "x", Modifiers::NONE)); + events.push(release(Key::X)); + keys.frame(&mut app, 0.0, events); + assert_eq!(steps(&app, n), [default.clone(), swap.clone()], "D first, then X's tap"); + assert!(app.hold_keys.pending.is_none()); + keys.frame(&mut app, 1.0, vec![release(Key::D)]); + assert_eq!(selected(&app), 1, "nothing waits after it"); + // Ended by V while X is still down: D, X's tap, then V. + let n = steps(&app, 0).len(); + let mut events = press(Key::D, "d", Modifiers::NONE); + events.extend(press(Key::X, "x", Modifiers::NONE)); + events.extend(press(Key::V, "v", Modifiers::NONE)); + keys.frame(&mut app, 2.0, events); + assert_eq!(steps(&app, n), [default, swap], "D first, then X's tap"); + assert_eq!(app.session.tool_id(), "selection", "then V"); + keys.press(&mut app, 2.5, Key::X, "x"); + keys.frame(&mut app, 2.6, vec![release(Key::X), release(Key::D), release(Key::V)]); + assert_eq!(steps(&app, n).len(), 2, "X's repeats run nothing"); + assert_eq!(selected(&app), 1, "and no hold"); + // Ended by a command chord (Deselect): D, X's tap, then the chord. + assert_eq!(crate::shortcut_editor::default_of("select.none"), Some("Cmd+Shift+A")); + app.run("paint.setFill", json!({"color": "#ff0000"})).unwrap(); + let n = steps(&app, 0).len(); + let mut events = press(Key::D, "d", Modifiers::NONE); + events.extend(press(Key::X, "x", Modifiers::NONE)); + let modifiers = Modifiers::COMMAND | Modifiers::SHIFT; + events.push(egui::Event::Key { key: Key::A, physical_key: Some(Key::A), pressed: true, repeat: false, modifiers }); + keys.frame(&mut app, 3.0, events); + assert_eq!(steps(&app, n), [label("paint.default"), label("paint.swap")], "D first, then X's tap"); + assert_eq!(selected(&app), 0, "then the chord"); +} + +/// The repeats of a key in the frame that starts its wait, and the text they type, stay out of the +/// frame. +#[test] +fn repeats_in_the_frame_that_starts_a_wait_stay_out_of_it() { + let mut app = swap_on_x(); + let keys = Keyboard::new(); + let n = steps(&app, 0).len(); + let mut events = press(Key::X, "x", Modifiers::NONE); + events.extend(press(Key::X, "x", Modifiers::NONE)); + events.extend(press(Key::X, "x", Modifiers::NONE)); + let left = keys.frame_left(&mut app, 0.0, events); + assert!(app.hold_keys.pending.is_some(), "X waits"); + assert!(!left.iter().any(|e| matches!(e, egui::Event::Text(_) | egui::Event::Key { pressed: true, .. })), "{left:?}"); + assert!(steps(&app, n).is_empty(), "the repeats run nothing"); } /// A press and its release in one frame are a tap, run in that frame. From f5afbf0acc3af5660ee8cc9f5923cf9576576010 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 11:07:17 -0800 Subject: [PATCH 04/17] Preferences: a restored Hold Shortcut Delay outside its range opens as the delay in use A settings file can hold a Hold Shortcut Delay outside 0.2 to 1 s. The dialog showed the value brought into range but kept the saved one, so OK sent it to prefs.set and failed. The dialog now opens with the delay in use, and OK keeps it. --- crates/ui-egui/src/prefs_dialog.rs | 5 +++++ crates/ui-egui/src/prefs_dialog/tests.rs | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/crates/ui-egui/src/prefs_dialog.rs b/crates/ui-egui/src/prefs_dialog.rs index c448754567..3794da2399 100644 --- a/crates/ui-egui/src/prefs_dialog.rs +++ b/crates/ui-egui/src/prefs_dialog.rs @@ -32,6 +32,11 @@ pub fn open(app: &mut VectorcraftApp, category: Option<&str>) { // One field per preference key or group (the flattener presets have commands of their own). let mut fields: Map = app.session.prefs.to_json().as_object().cloned().unwrap_or_default(); fields.retain(|k, _| vectorcraft_engine::cmd::prefscmds::spec(k).is_some() || PREF_GROUPS.contains(&k.as_str())); + // A restored settings file can hold a Hold Shortcut Delay outside its range: the dialog shows, + // and OK sets, the delay in use. + if fields.contains_key("keyHoldDelay") { + fields.insert("keyHoldDelay".into(), json!(app.session.prefs.key_hold_delay())); + } // Units ▸ General shows (and OK sets) the open document's units. if let Some(st) = app.session.active() { fields.insert("unitsGeneral".into(), json!(st.doc.units.key())); diff --git a/crates/ui-egui/src/prefs_dialog/tests.rs b/crates/ui-egui/src/prefs_dialog/tests.rs index 973a0111f7..2240ddedd2 100644 --- a/crates/ui-egui/src/prefs_dialog/tests.rs +++ b/crates/ui-egui/src/prefs_dialog/tests.rs @@ -1136,6 +1136,19 @@ fn hold_shortcut_delay_dims_without_hold_shortcuts() { } } +/// A restored Hold Shortcut Delay outside its range opens as the delay in use, and OK keeps it. +#[test] +fn a_restored_hold_shortcut_delay_outside_its_range_opens_as_the_delay_in_use() { + for (saved, used) in [(5.0, 1.0), (0.05, 0.2)] { + let mut a = app(); + a.session.prefs.key_hold_delay = saved; + open(&mut a, Some("General")); + assert_eq!(a.ui.dialog.as_ref().unwrap().fields["keyHoldDelay"], json!(used), "{saved}"); + confirm(&mut a).unwrap(); + assert_eq!(a.session.prefs.key_hold_delay, used, "{saved}"); + } +} + /// Type › Show samples on white: its checkbox is dimmed while Enable in-menu font previews is /// unchecked in the dialog, and a click on it then leaves the setting as it was. #[test] From ef3df8f8075e7b64acd6bda6a7887720d11d12bd Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 12:20:27 -0800 Subject: [PATCH 05/17] Shortcuts: a key typed before a wait that opens a dialog keeps later keys from it When a wait starts and ends in one frame and a key typed before it opens a dialog, the frame's key events and texts are taken from the position of that key's first event (its press, or its text when the text came first), not from the event that ended the wait. An Enter pressed between the two no longer reaches the dialog. --- crates/ui-egui/src/shortcuts/hold_keys.rs | 16 +++++++++------- .../ui-egui/src/shortcuts/hold_keys/tests.rs | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/shortcuts/hold_keys.rs b/crates/ui-egui/src/shortcuts/hold_keys.rs index b494050bd2..fd8f8842fd 100644 --- a/crates/ui-egui/src/shortcuts/hold_keys.rs +++ b/crates/ui-egui/src/shortcuts/hold_keys.rs @@ -211,7 +211,8 @@ fn tool_takes(app: &mut VectorcraftApp, key: Key, text: &str) -> bool { /// Runs the single-key shortcuts of the texts typed before the event at `start` that no wait took, /// in order, as the frame's shortcuts would run them, and takes them and their presses from the /// frame. A text typed with Cmd, Ctrl or Alt, by a key the active tool takes, or with no shortcut, -/// is left to the frame. True when one opened a dialog or the palette. +/// is left to the frame. When one opened a dialog or the palette, the position of its first event +/// in the frame: its press, or its text where the text came first (the web build). fn run_typed_before( app: &mut VectorcraftApp, ctx: &egui::Context, @@ -219,7 +220,7 @@ fn run_typed_before( typed_by: &[Option], start: usize, taken: &mut Vec, -) -> bool { +) -> Option { for (k, e) in events.iter().enumerate().take(start) { let egui::Event::Text(text) = e else { continue }; let by = typed_by.get(k).copied().flatten(); @@ -246,10 +247,10 @@ fn run_typed_before( taken.push(k); taken.extend(by); if super::run_single_key(app, ctx, &chords, key, repeat) { - return true; + return Some(by.map_or(k, |b| b.min(k))); } } - false + None } /// Before the frame's shortcuts run: goes through the frame's events in order. A release of the @@ -301,10 +302,10 @@ pub(super) fn intake(app: &mut VectorcraftApp, ctx: &egui::Context) -> bool { // A key typed before it that opened a dialog or the palette ends the wait without // running it. if let Some(start) = started.take() - && run_typed_before(app, ctx, &events, &typed_by, start, &mut taken) + && let Some(opened) = run_typed_before(app, ctx, &events, &typed_by, start, &mut taken) { cancel(app, ctx); - stop_at = Some(j); + stop_at = Some(opened); break; } if settle(app, ctx, hold, down) { @@ -351,7 +352,8 @@ pub(super) fn intake(app: &mut VectorcraftApp, ctx: &egui::Context) -> bool { app.hold_keys.pending = Some(Pending { entry, chords, key: *key, physical: *physical_key, mods: *m, since: now, delay, viewport }); } // Take the waiting presses and their texts, and after a result that opened a dialog, the key - // event that ended the wait and every later key event and text of the frame, with the text a + // event that ended the wait (or the typed key that opened the dialog, when that came earlier) + // and every later key event and text of the frame, with the text a // press typed before it (the web build sends a press's text first): none of them reaches the // dialog. ctx.input_mut(|i| { diff --git a/crates/ui-egui/src/shortcuts/hold_keys/tests.rs b/crates/ui-egui/src/shortcuts/hold_keys/tests.rs index 4e745510fe..1413e80e97 100644 --- a/crates/ui-egui/src/shortcuts/hold_keys/tests.rs +++ b/crates/ui-egui/src/shortcuts/hold_keys/tests.rs @@ -587,6 +587,24 @@ fn the_key_that_ends_a_wait_does_not_reach_the_dialog_it_opened() { assert_eq!(fill(&app), "#ff0000"); } +/// A key typed before a wait that starts and ends in one frame, and that opens a dialog, keeps the +/// frame's later keys from the dialog, the ones before the waiting key included. +#[test] +fn a_key_typed_before_a_wait_does_not_let_later_keys_reach_its_dialog() { + let mut app = app_with(true); + app.run("shortcuts.set", json!({"id": "edit.preferences", "shortcut": "D", "force": true})).unwrap(); + app.run("shortcuts.set", json!({"id": "paint.swap", "hold": "X"})).unwrap(); + let keys = Keyboard::new(); + let mut events = press(Key::D, "d", Modifiers::NONE); + events.push(egui::Event::Key { key: Key::Enter, physical_key: Some(Key::Enter), pressed: true, repeat: false, modifiers: Modifiers::NONE }); + events.extend(press(Key::X, "x", Modifiers::NONE)); + events.push(release(Key::X)); + let left = keys.frame_left(&mut app, 0.0, events); + assert!(app.ui.dialog.is_some(), "D opened Preferences"); + assert!(!left.iter().any(|e| matches!(e, egui::Event::Key { key: Key::Enter, .. })), "{left:?}"); + assert_eq!(fill(&app), "#ff0000"); +} + /// On the web build a press's text comes before it: the text of the key that ends such a wait /// does not reach the dialog either. #[test] From 2caaabbc8fc62edf611b0869f1380e9db4c67d2e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 12:47:02 -0800 Subject: [PATCH 06/17] Shortcuts: a chord before a key with a hold shortcut keeps its order in a frame When a key with a hold shortcut is pressed and released in the same frame after a chord with Cmd, Ctrl or Alt, the key no longer waits: it goes back to the frame, which handles it as it does with Hold Shortcuts off. Its tap no longer runs before the chord, so Cmd+Z followed by X in one frame no longer undoes X's change instead of the earlier edit. --- crates/ui-egui/src/shortcuts/hold_keys.rs | 31 +++++++++++++++---- .../ui-egui/src/shortcuts/hold_keys/tests.rs | 24 ++++++++++++++ 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/shortcuts/hold_keys.rs b/crates/ui-egui/src/shortcuts/hold_keys.rs index fd8f8842fd..8bec32c8bd 100644 --- a/crates/ui-egui/src/shortcuts/hold_keys.rs +++ b/crates/ui-egui/src/shortcuts/hold_keys.rs @@ -208,6 +208,15 @@ fn tool_takes(app: &mut VectorcraftApp, key: Key, text: &str) -> bool { tool_key.is_some_and(|k| app.session.tool_claims_key(k, view)) } +/// Is there a press with Cmd, Ctrl or Alt before the event at `start` that no wait took? +fn chord_before(events: &[egui::Event], start: usize, taken: &[usize]) -> bool { + events.iter().enumerate().take(start).any(|(k, e)| { + !taken.contains(&k) + && matches!(e, egui::Event::Key { key, pressed: true, modifiers: m, .. } + if !super::is_modifier(*key) && (m.command || m.ctrl || m.alt || m.mac_cmd)) + }) +} + /// Runs the single-key shortcuts of the texts typed before the event at `start` that no wait took, /// in order, as the frame's shortcuts would run them, and takes them and their presses from the /// frame. A text typed with Cmd, Ctrl or Alt, by a key the active tool takes, or with no shortcut, @@ -259,7 +268,8 @@ fn run_typed_before( /// went down; and a new press of a key with a hold shortcut starts a wait, taking the press and /// its text from the frame, with the key's repeats that follow in the frame and their text. When a /// wait that started in this frame also ends in it, the keys typed before its key run first -/// ([`run_typed_before`]), so they act in the order they went down. Then a wait +/// ([`run_typed_before`]), so they act in the order they went down; after a chord with Cmd, Ctrl +/// or Alt before its key, the key goes back to the frame instead ([`chord_before`]). Then a wait /// whose delay has passed with the key down runs the hold shortcut. True when a result opened a /// dialog or the palette: the rest of the frame's keys are dropped and no other shortcut runs. pub(super) fn intake(app: &mut VectorcraftApp, ctx: &egui::Context) -> bool { @@ -299,16 +309,25 @@ pub(super) fn intake(app: &mut VectorcraftApp, ctx: &egui::Context) -> bool { } }; if let Some((hold, down)) = ended { - // A key typed before it that opened a dialog or the palette ends the wait without - // running it. - if let Some(start) = started.take() + let start = started.take(); + // After a chord with Cmd, Ctrl or Alt pressed before it, which the frame's shortcuts + // run, the key goes back to the frame without waiting, so the frame handles it as it + // does with Hold Shortcuts off and its tap does not run before the chord. + if let Some(start) = start + && chord_before(&events, start, &taken) + { + cancel(app, ctx); + let text = text_of(start).map(|(t, _)| t); + taken.retain(|&k| k != start && Some(k) != text); + } else if let Some(start) = start && let Some(opened) = run_typed_before(app, ctx, &events, &typed_by, start, &mut taken) { + // A key typed before it that opened a dialog or the palette ends the wait + // without running it. cancel(app, ctx); stop_at = Some(opened); break; - } - if settle(app, ctx, hold, down) { + } else if settle(app, ctx, hold, down) { stop_at = Some(j); break; } diff --git a/crates/ui-egui/src/shortcuts/hold_keys/tests.rs b/crates/ui-egui/src/shortcuts/hold_keys/tests.rs index 1413e80e97..13255e273c 100644 --- a/crates/ui-egui/src/shortcuts/hold_keys/tests.rs +++ b/crates/ui-egui/src/shortcuts/hold_keys/tests.rs @@ -395,6 +395,30 @@ fn a_wait_ended_in_its_frame_runs_after_the_keys_before_it() { assert_eq!(selected(&app), 0, "then the chord"); } +/// A command chord (Undo) pressed before a wait that starts and ends in one frame runs first: the +/// key's tap does not run before it, and the frame acts as it does with Hold Shortcuts off. +#[test] +fn a_chord_before_a_wait_ended_in_its_frame_runs_first() { + assert_eq!(crate::shortcut_editor::default_of("edit.undo"), Some("Cmd+Z")); + let frame = |app: &mut VectorcraftApp| { + app.run("paint.setFill", json!({"color": "#00ff00"})).unwrap(); + let mut events = + vec![egui::Event::Key { key: Key::Z, physical_key: Some(Key::Z), pressed: true, repeat: false, modifiers: Modifiers::COMMAND }]; + events.extend(press(Key::X, "x", Modifiers::NONE)); + events.push(release(Key::X)); + Keyboard::new().frame(app, 0.0, events); + (fill(app), selected(app)) + }; + let mut off = swap_on_x(); + off.run("prefs.set", json!({"key": "holdShortcuts", "value": false})).unwrap(); + let off = frame(&mut off); + let mut app = swap_on_x(); + let on = frame(&mut app); + assert_eq!(on.0, "#ff0000", "Undo restores the red fill and does not undo X's swap"); + assert_eq!(on, off); + assert!(app.hold_keys.pending.is_none()); +} + /// The repeats of a key in the frame that starts its wait, and the text they type, stay out of the /// frame. #[test] From 87c5278d032115b95520069aa9a20b46dcce7111 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 13:31:32 -0800 Subject: [PATCH 07/17] Shortcuts: a command listed only with a shortcut keeps a hold shortcut only with one A command that needs a value, such as Transparency, is listed in the editor only while it has a shortcut. shortcuts.set now refuses a hold shortcut for such a command without a shortcut, and the command loses its hold shortcut when its shortcut is cleared or given to another entry, through shortcuts.set, the Keyboard Shortcuts dialog or an imported set. Its key no longer runs a command the editor does not show, and it is free for another entry without a conflict. --- crates/mcp/src/ui_catalog.rs | 2 +- crates/ui-egui/src/menus/ui_commands.rs | 2 +- crates/ui-egui/src/shortcut_editor.rs | 50 +++++++++++++++++++++++-- docs/mcp.md | 4 +- 4 files changed, 52 insertions(+), 6 deletions(-) diff --git a/crates/mcp/src/ui_catalog.rs b/crates/mcp/src/ui_catalog.rs index 2974846982..543026c385 100644 --- a/crates/mcp/src/ui_catalog.rs +++ b/crates/mcp/src/ui_catalog.rs @@ -177,7 +177,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "shortcuts.set", "Set Keyboard Shortcut", "", - "{id: command id or tool:, shortcut?: \"Cmd+Shift+K\" | \"\" (none) | null (default), hold?: a character key alone or with Shift (\"X\", \"Shift+X\", \".\") | \"\" | null (none), force?} → {id, shortcut, hold, removedFrom}; `hold` alone leaves the shortcut as it is; a hold shortcut acts while the holdShortcuts preference is on", + "{id: command id or tool:, shortcut?: \"Cmd+Shift+K\" | \"\" (none) | null (default), hold?: a character key alone or with Shift (\"X\", \"Shift+X\", \".\") | \"\" | null (none), force?} → {id, shortcut, hold, removedFrom}; `hold` alone leaves the shortcut as it is; a command listed only with a shortcut takes a hold only with one and loses it with the shortcut; a hold shortcut acts while the holdShortcuts preference is on", ), ("shortcuts.list", "List Keyboard Shortcuts", "", "{query?} → [{id, label, group, shortcut, hold, default, overridden}]"), ("shortcuts.conflicts", "Keyboard Shortcut Conflicts", "", "{} → [{shortcut, ids}]"), diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index 6d6fb85307..b2647ed3eb 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -178,7 +178,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "shortcuts.set", "Set Keyboard Shortcut", "", - "{id: command id or tool:, shortcut?: \"Cmd+Shift+K\" | \"\" (none) | null (default), hold?: a character key alone or with Shift (\"X\", \"Shift+X\", \".\") | \"\" | null (none), force?} → {id, shortcut, hold, removedFrom}; `hold` alone leaves the shortcut as it is; a hold shortcut acts while the holdShortcuts preference is on", + "{id: command id or tool:, shortcut?: \"Cmd+Shift+K\" | \"\" (none) | null (default), hold?: a character key alone or with Shift (\"X\", \"Shift+X\", \".\") | \"\" | null (none), force?} → {id, shortcut, hold, removedFrom}; `hold` alone leaves the shortcut as it is; a command listed only with a shortcut takes a hold only with one and loses it with the shortcut; a hold shortcut acts while the holdShortcuts preference is on", ), ("shortcuts.list", "List Keyboard Shortcuts", "", "{query?} → [{id, label, group, shortcut, hold, default, overridden}]"), ("shortcuts.conflicts", "Keyboard Shortcut Conflicts", "", "{} → [{shortcut, ids}]"), diff --git a/crates/ui-egui/src/shortcut_editor.rs b/crates/ui-egui/src/shortcut_editor.rs index a1cb43d874..106c04405b 100644 --- a/crates/ui-egui/src/shortcut_editor.rs +++ b/crates/ui-egui/src/shortcut_editor.rs @@ -1165,9 +1165,20 @@ pub fn hold_of(holds: &Holds, key: &str) -> Option { } /// The entry whose usable hold shortcut is `chord`: the first in `holds`' order when several are. -/// An entry no longer listed (a removed plug-in's) keeps its text but does not hold. +/// An entry no longer listed (a removed plug-in's, or one that [`needs_a_value`] whose shortcut +/// was taken away) keeps its text but does not hold. pub(crate) fn hold_for<'a>(holds: &'a Holds, chord: &craft_keymap::Chord) -> Option<&'a str> { - holds.iter().find(|(k, t)| hold_chord(t).is_ok_and(|c| c == *chord) && entry(k).is_some()).map(|(k, _)| k.as_str()) + let mirror = current(); + holds + .iter() + .find(|(k, t)| hold_chord(t).is_ok_and(|c| c == *chord) && entry(k).is_some_and(|e| listed(mirror.keymap.overrides(), &e))) + .map(|(k, _)| k.as_str()) +} + +/// Removes the hold shortcuts of the entries the editor does not list under `overrides`: one that +/// [`needs_a_value`] loses its hold with its shortcut. A removed plug-in's entry keeps its hold. +fn drop_unlisted_holds(holds: &mut Holds, overrides: &Overrides) { + holds.retain(|k, _| entry(k).is_none_or(|e| listed(overrides, &e))); } /// Sets (`Some`) or removes (`None` or `""`) the hold shortcut of `key`. Another entry that holds @@ -1540,6 +1551,10 @@ pub fn run_command(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option Option Option Err("no file reader".into()), } }; - data.and_then(|v| Ok((import_json(&v)?, import_holds(&v)?))).map(|((set, ov), holds)| { + data.and_then(|v| Ok((import_json(&v)?, import_holds(&v)?))).map(|((set, ov), mut holds)| { let n = ov.len(); + drop_unlisted_holds(&mut holds, &ov); app.ui.shortcut_overrides = ov; app.ui.shortcut_holds = holds; app.ui.shortcut_set = set; @@ -2066,6 +2083,7 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) { if let Cow::Owned(km) = &km { d.fields.insert("overrides".into(), stored::to_value(&saved_overrides(km.overrides(), &saved))); } + drop_unlisted_holds(&mut holds, km.overrides()); d.fields.insert("holds".into(), json!(holds)); if d.str("__recording").is_empty() { d.fields.insert("__recordingHold".into(), json!(false)); @@ -3580,6 +3598,32 @@ mod tests { assert_eq!(app.ui.shortcut_holds.keys().collect::>(), ["select.none"]); } + /// A command the editor lists only with a shortcut (Transparency needs a value) takes a hold + /// shortcut only with one, and loses its hold, as it stops being listed, when the shortcut is + /// taken away: by clearing it or by giving it to another command. + #[test] + fn a_hold_shortcut_needs_a_listed_entry() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + assert!(needs_a_value("transparency.set")); + let r = app.run("shortcuts.set", json!({"id": "transparency.set", "hold": "Q"})); + assert!(r.is_err(), "{r:?}"); + assert!(app.ui.shortcut_holds.is_empty() && app.ui.shortcut_overrides.is_empty()); + let q = vc_chord("Q").unwrap(); + app.run("shortcuts.set", json!({"id": "transparency.set", "shortcut": "Cmd+Alt+Shift+F9", "hold": "Q"})).unwrap(); + assert_eq!(hold_for(&app.ui.shortcut_holds, &q), Some("transparency.set")); + let rows = with_steady_plugins(|| app.run("shortcuts.list", json!({"query": "transparency.set"})).unwrap()); + assert!(rows.as_array().unwrap().iter().any(|r| r["id"] == "transparency.set" && r["hold"] == "Q"), "{rows}"); + app.run("shortcuts.set", json!({"id": "transparency.set", "shortcut": ""})).unwrap(); + assert_eq!(hold_for(&app.ui.shortcut_holds, &q), None); + assert!(app.ui.shortcut_holds.is_empty(), "{:?}", app.ui.shortcut_holds); + // The key is free for another command, with no conflict left behind. + app.run("shortcuts.set", json!({"id": "paint.swap", "hold": "Q"})).unwrap(); + assert_eq!(app.run("shortcuts.conflicts", json!({})).unwrap(), json!([])); + app.run("shortcuts.set", json!({"id": "transparency.set", "shortcut": "Cmd+Alt+Shift+F9", "hold": "Shift+Q"})).unwrap(); + app.run("shortcuts.set", json!({"id": "edit.duplicate", "shortcut": "Cmd+Alt+Shift+F9", "force": true})).unwrap(); + assert_eq!(app.ui.shortcut_holds.keys().collect::>(), ["paint.swap"]); + } + /// Reset All and a preset clear the hold shortcuts; two entries holding one key are a conflict. #[test] fn hold_shortcut_conflicts_reset_and_presets() { diff --git a/docs/mcp.md b/docs/mcp.md index 6b5e55116c..ea0ce74230 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -6649,7 +6649,9 @@ has a hold shortcut, or a key the active tool uses itself (E with the Extend Pat `shortcuts.set {id, hold}` sets a hold shortcut, and `hold: ""` or `null` removes it; `hold` alone leaves the entry's shortcut as it is, and a key that another entry already holds is refused unless `force` is true. Hold shortcuts are kept apart from shortcuts: Use Default, Clear and `shortcut: null` leave them, and `overridden` in `shortcuts.list` is -about the shortcut only. `shortcuts.list` rows give the hold shortcut as `hold`, `shortcuts.conflicts` lists a key two +about the shortcut only. A command the editor lists only while it has a shortcut (one that needs a value, such as +`transparency.set`) takes a hold shortcut only with a shortcut, and loses its hold shortcut when its shortcut is cleared +or given to another entry. `shortcuts.list` rows give the hold shortcut as `hold`, `shortcuts.conflicts` lists a key two entries hold as `"Hold X"`, and Reset to Defaults and a preset remove every hold shortcut. `shortcuts.export` writes them as a `holds` object (entry id to key) when there are any, and `shortcuts.import` reads it; a file without `holds` has none, and a `holds` value that is not a usable hold shortcut fails the import, which then changes nothing. From 3046868fbcc0fb1151d1728780a52b06ae41d51d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 16:02:53 -0800 Subject: [PATCH 08/17] Shortcuts: a shifted key with a hold shortcut holds before the character it types When one entry holds a key with Shift (Shift+1) and another the character that key types (`!`), holding Shift+1 runs the hold shortcut of Shift+1. Before, the typed character was matched first, so the Shift+1 hold shortcut could not run. --- crates/ui-egui/src/shortcuts/hold_keys.rs | 14 +++++++------- crates/ui-egui/src/shortcuts/hold_keys/tests.rs | 14 ++++++++++++++ docs/mcp.md | 3 ++- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/crates/ui-egui/src/shortcuts/hold_keys.rs b/crates/ui-egui/src/shortcuts/hold_keys.rs index 8bec32c8bd..7cb360baf8 100644 --- a/crates/ui-egui/src/shortcuts/hold_keys.rs +++ b/crates/ui-egui/src/shortcuts/hold_keys.rs @@ -163,19 +163,19 @@ fn settle(app: &mut VectorcraftApp, ctx: &egui::Context, hold: bool, down: bool) opened } -/// The chords a press names for a hold shortcut, first match first: those of the text it typed, as -/// a single-key shortcut reads them, then the key itself with its Shift (Shift+1 typing `!`). A -/// letter names only the chord with its own Shift state: a hold on X does not catch Shift+X. +/// The chords a press names for a hold shortcut, first match first: the key itself with its Shift +/// (Shift+1 typing `!`), then those of the text it typed, as a single-key shortcut reads them. When +/// one entry holds Shift+1 and another `!`, Shift+1 runs the first. A letter names only the chord +/// with its own Shift state: a hold on X does not catch Shift+X. fn press_chords(text: &str, key: Key, m: Modifiers) -> Vec { let mut chords = super::text_chords(text, m, Some(key)); if !text.is_empty() && text.chars().all(char::is_alphabetic) { chords.retain(|c| c.mods.shift == m.shift); } let shift = Modifiers { shift: m.shift, ..Modifiers::NONE }; - if let Some(c) = crate::shortcut_editor::chord_from_event(key, shift).and_then(|t| crate::keymap::vc_chord(&t)) - && !chords.contains(&c) - { - chords.push(c); + if let Some(c) = crate::shortcut_editor::chord_from_event(key, shift).and_then(|t| crate::keymap::vc_chord(&t)) { + chords.retain(|t| *t != c); + chords.insert(0, c); } chords } diff --git a/crates/ui-egui/src/shortcuts/hold_keys/tests.rs b/crates/ui-egui/src/shortcuts/hold_keys/tests.rs index 13255e273c..e8838fcfec 100644 --- a/crates/ui-egui/src/shortcuts/hold_keys/tests.rs +++ b/crates/ui-egui/src/shortcuts/hold_keys/tests.rs @@ -530,6 +530,20 @@ fn a_shifted_digit_holds_when_it_types_its_symbol() { assert_eq!(fill(&app), "#0000ff"); } +/// With one entry holding Shift+1 and another `!`, which Shift+1 types, holding Shift+1 runs the +/// entry that holds the key itself. +#[test] +fn a_shifted_digit_holds_before_the_symbol_it_types() { + let mut app = app_with(true); + app.run("shortcuts.set", json!({"id": "paint.swap", "hold": "Shift+1"})).unwrap(); + app.run("shortcuts.set", json!({"id": "select.all", "hold": "!"})).unwrap(); + assert_eq!(app.ui.shortcut_holds.len(), 2); + let keys = Keyboard::new(); + keys.frame(&mut app, 0.0, press(Key::Num1, "!", Modifiers::SHIFT)); + keys.frame(&mut app, 0.4, vec![]); + assert_eq!(fill(&app), "#0000ff", "Shift+1's hold ran"); +} + /// A quick press of a shifted key with a hold shortcut runs what the key runs without one: a /// shortcut on Shift+. (typing `>`) runs, and Shift+1 (typing `!`) runs what `!` runs. #[test] diff --git a/docs/mcp.md b/docs/mcp.md index ea0ce74230..5d050c1497 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -6644,7 +6644,8 @@ go; let go sooner, it runs what the key runs without a hold shortcut, at the rel waits, or Cmd, Ctrl or Alt pressed then, ends the wait first, so keys act in the order they went down. The window losing the keyboard, a dialog, a text field, Presentation Mode or an input method composition ends the wait and runs nothing. Keys without a hold shortcut run on their press as before, and so does a letter with Shift when only the letter alone -has a hold shortcut, or a key the active tool uses itself (E with the Extend Path tool). +has a hold shortcut, or a key the active tool uses itself (E with the Extend Path tool). When one entry holds a key with +Shift (Shift+1) and another the character it types (`!`), that key runs the hold shortcut of the first. `shortcuts.set {id, hold}` sets a hold shortcut, and `hold: ""` or `null` removes it; `hold` alone leaves the entry's shortcut as it is, and a key that another entry already holds is refused unless `force` is true. Hold shortcuts are From cd3b09051803ac10fa8837fa78dff844e15e825f Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 16:03:01 -0800 Subject: [PATCH 09/17] Shortcuts: after a chord before a hold key, the key's repeats reach the frame When a command chord comes before a key with a hold shortcut in one frame, and the key's wait ends in that frame, the key goes back to the frame as with Hold Shortcuts off. Its repeats in that frame, the text they type and its repeats in later frames now go back too; before, they were held back until the key was let go. --- crates/ui-egui/src/shortcuts/hold_keys.rs | 21 ++++++------- .../ui-egui/src/shortcuts/hold_keys/tests.rs | 30 +++++++++++++++++++ 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/crates/ui-egui/src/shortcuts/hold_keys.rs b/crates/ui-egui/src/shortcuts/hold_keys.rs index 7cb360baf8..b504be57d8 100644 --- a/crates/ui-egui/src/shortcuts/hold_keys.rs +++ b/crates/ui-egui/src/shortcuts/hold_keys.rs @@ -283,9 +283,9 @@ pub(super) fn intake(app: &mut VectorcraftApp, ctx: &egui::Context) -> bool { let text_of = |k: usize| typed_by.iter().position(|by| *by == Some(k)).and_then(|j| events.get(j).map(|e| (j, e))); let mut taken: Vec = vec![]; let mut stop_at = None; - // The press of a wait that started in this frame: when the wait also ends in this frame, the - // keys typed before it run first. - let mut started: Option = None; + // The press of a wait that started in this frame, and how many events were taken before it: + // when the wait also ends in this frame, the keys typed before it run first. + let mut started: Option<(usize, usize)> = None; for (j, e) in events.iter().enumerate() { if let Some(p) = app.hold_keys.pending.as_ref().filter(|p| p.viewport == viewport) { let overdue = now - p.since >= p.delay; @@ -312,14 +312,15 @@ pub(super) fn intake(app: &mut VectorcraftApp, ctx: &egui::Context) -> bool { let start = started.take(); // After a chord with Cmd, Ctrl or Alt pressed before it, which the frame's shortcuts // run, the key goes back to the frame without waiting, so the frame handles it as it - // does with Hold Shortcuts off and its tap does not run before the chord. - if let Some(start) = start + // does with Hold Shortcuts off and its tap does not run before the chord. Its press, + // its repeats and their texts stay in the frame, and its later repeats reach later + // frames. + if let Some((start, before)) = start && chord_before(&events, start, &taken) { - cancel(app, ctx); - let text = text_of(start).map(|(t, _)| t); - taken.retain(|&k| k != start && Some(k) != text); - } else if let Some(start) = start + app.hold_keys.pending = None; + taken.truncate(before); + } else if let Some((start, _)) = start && let Some(opened) = run_typed_before(app, ctx, &events, &typed_by, start, &mut taken) { // A key typed before it that opened a dialog or the palette ends the wait @@ -349,7 +350,7 @@ pub(super) fn intake(app: &mut VectorcraftApp, ctx: &egui::Context) -> bool { if tool_takes(app, *key, text) { continue; } - started = Some(j); + started = Some((j, taken.len())); taken.extend([j, t]); // The key's repeats in this frame, and the text they type, stay out of the frame too. for (r, later) in events.iter().enumerate().skip(j + 1) { diff --git a/crates/ui-egui/src/shortcuts/hold_keys/tests.rs b/crates/ui-egui/src/shortcuts/hold_keys/tests.rs index e8838fcfec..09d4b41689 100644 --- a/crates/ui-egui/src/shortcuts/hold_keys/tests.rs +++ b/crates/ui-egui/src/shortcuts/hold_keys/tests.rs @@ -419,6 +419,36 @@ fn a_chord_before_a_wait_ended_in_its_frame_runs_first() { assert!(app.hold_keys.pending.is_none()); } +/// After a command chord before a wait that starts and ends in one frame, the key's repeats in +/// that frame and in later ones, and the text they type, reach the frame as with Hold Shortcuts +/// off. +#[test] +fn a_chord_before_a_wait_leaves_the_key_repeats_to_the_frame() { + let run = |app: &mut VectorcraftApp| { + app.run("paint.setFill", json!({"color": "#00ff00"})).unwrap(); + let n = steps(app, 0).len(); + let keys = Keyboard::new(); + let mut events = + vec![egui::Event::Key { key: Key::Z, physical_key: Some(Key::Z), pressed: true, repeat: false, modifiers: Modifiers::COMMAND }]; + events.extend(press(Key::X, "x", Modifiers::NONE)); + events.extend(press(Key::X, "x", Modifiers::NONE)); + events.extend(press(Key::D, "d", Modifiers::NONE)); + let first = keys.frame_left(app, 0.0, events); + let mut events = press(Key::X, "x", Modifiers::NONE); + events.extend([release(Key::X), release(Key::D)]); + let second = keys.frame_left(app, 0.05, events); + (steps(app, n), first, second, fill(app)) + }; + let mut off = swap_on_x(); + off.run("prefs.set", json!({"key": "holdShortcuts", "value": false})).unwrap(); + let off = run(&mut off); + let mut app = swap_on_x(); + let on = run(&mut app); + assert_eq!(on, off); + assert!(app.hold_keys.pending.is_none()); + assert!(app.hold_keys.swallowed.is_empty()); +} + /// The repeats of a key in the frame that starts its wait, and the text they type, stay out of the /// frame. #[test] From 5255d612731b9947e97341e3dc420653096e9ac3 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 16:03:02 -0800 Subject: [PATCH 10/17] Tests: a key typed before a wait keeps later letters from its dialog The test for a key typed before a wait that opens a dialog now presses a letter between the two keys and checks that neither its press nor its text reaches the dialog. A second test sends the same keys in the web build's order, with each text before its press. --- .../ui-egui/src/shortcuts/hold_keys/tests.rs | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/shortcuts/hold_keys/tests.rs b/crates/ui-egui/src/shortcuts/hold_keys/tests.rs index 09d4b41689..86ee5f5c0c 100644 --- a/crates/ui-egui/src/shortcuts/hold_keys/tests.rs +++ b/crates/ui-egui/src/shortcuts/hold_keys/tests.rs @@ -664,12 +664,35 @@ fn a_key_typed_before_a_wait_does_not_let_later_keys_reach_its_dialog() { app.run("shortcuts.set", json!({"id": "paint.swap", "hold": "X"})).unwrap(); let keys = Keyboard::new(); let mut events = press(Key::D, "d", Modifiers::NONE); - events.push(egui::Event::Key { key: Key::Enter, physical_key: Some(Key::Enter), pressed: true, repeat: false, modifiers: Modifiers::NONE }); + events.extend(press(Key::A, "a", Modifiers::NONE)); events.extend(press(Key::X, "x", Modifiers::NONE)); events.push(release(Key::X)); let left = keys.frame_left(&mut app, 0.0, events); assert!(app.ui.dialog.is_some(), "D opened Preferences"); - assert!(!left.iter().any(|e| matches!(e, egui::Event::Key { key: Key::Enter, .. })), "{left:?}"); + assert!(!left.iter().any(|e| matches!(e, egui::Event::Text(_) | egui::Event::Key { key: Key::A, pressed: true, .. })), "{left:?}"); + assert_eq!(fill(&app), "#ff0000"); +} + +/// On the web build, where each press's text comes before it, a key typed before a wait that +/// starts and ends in one frame, and that opens a dialog, keeps the frame's later keys from the +/// dialog too. +#[test] +fn a_key_typed_before_a_wait_on_the_web_build_does_not_let_later_keys_reach_its_dialog() { + let mut app = app_with(true); + app.run("shortcuts.set", json!({"id": "edit.preferences", "shortcut": "D", "force": true})).unwrap(); + app.run("shortcuts.set", json!({"id": "paint.swap", "hold": "X"})).unwrap(); + let keys = Keyboard::new(); + let web = |key: Key, text: &str| { + [egui::Event::Text(text.into()), egui::Event::Key { key, physical_key: Some(key), pressed: true, repeat: false, modifiers: Modifiers::NONE }] + }; + let mut events = vec![]; + for (key, text) in [(Key::D, "d"), (Key::A, "a"), (Key::X, "x")] { + events.extend(web(key, text)); + } + events.push(release(Key::X)); + let left = keys.frame_left(&mut app, 0.0, events); + assert!(app.ui.dialog.is_some(), "D opened Preferences"); + assert!(!left.iter().any(|e| matches!(e, egui::Event::Text(_) | egui::Event::Key { pressed: true, .. })), "{left:?}"); assert_eq!(fill(&app), "#ff0000"); } From 4d9dde74610b1b1c855ea09e2d3479398bf3db3e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 16:19:00 -0800 Subject: [PATCH 11/17] Shortcuts: OK in Keyboard Shortcuts saves Hold Shortcuts and its delay When OK in Edit > Keyboard Shortcuts changes Hold Shortcuts or the Hold Shortcut Delay, the preferences are copied into the saved UI state and the host is asked to write the preferences file, as OK in Preferences does. Before, the change waited for the host's delayed save. --- crates/ui-egui/src/shortcut_editor.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/shortcut_editor.rs b/crates/ui-egui/src/shortcut_editor.rs index 106c04405b..b9bfe65546 100644 --- a/crates/ui-egui/src/shortcut_editor.rs +++ b/crates/ui-egui/src/shortcut_editor.rs @@ -1500,6 +1500,9 @@ pub fn confirm(app: &mut VectorcraftApp) -> Result { let prefs = &app.session.prefs; if d.kind == "shortcuts" && (on != prefs.hold_shortcuts || delay != prefs.key_hold_delay()) { app.run("prefs.set", json!({"values": {"holdShortcuts": on, "keyHoldDelay": delay}})).map_err(|e| e.to_string())?; + // Saved as OK in Preferences saves them. + crate::prefs_dialog::snapshot(app); + app.prefs_changed = true; } app.ui.shortcut_overrides = dialog_overrides(&d); app.ui.shortcut_holds = dialog_holds(&d); @@ -3741,8 +3744,8 @@ mod tests { } /// Hold Shortcuts is off by default: the dialog shows its checkbox and no Hold column. Turned - /// on, the dialog shows the column and the delay, and OK turns hold shortcuts on; Cancel keeps - /// them off. + /// on, the dialog shows the column and the delay, and OK turns hold shortcuts on and asks the + /// host to write the preferences file; Cancel keeps them off. #[test] fn the_hold_shortcuts_checkbox_shows_the_hold_column() { let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); @@ -3756,6 +3759,7 @@ mod tests { assert!(on.iter().any(|t| t == "Hold") && on.iter().any(|t| t == "Hold Shortcut Delay"), "{on:?}"); app.ui.dialog = None; assert!(!app.session.prefs.hold_shortcuts, "Cancel keeps them off"); + assert!(!app.take_prefs_changed(), "nothing to write after Cancel"); open(&mut app); let d = app.ui.dialog.as_mut().unwrap(); d.fields.insert("holdShortcuts".into(), json!(true)); @@ -3763,6 +3767,9 @@ mod tests { confirm(&mut app).unwrap(); assert!(app.session.prefs.hold_shortcuts); assert_eq!(app.session.prefs.key_hold_delay, 0.5); + assert!(app.take_prefs_changed(), "OK asks the host to write the preferences file"); + assert_eq!(app.ui.engine_prefs["holdShortcuts"], json!(true)); + assert_eq!(app.ui.engine_prefs["keyHoldDelay"], json!(0.5)); } /// The info button shows how hold shortcuts work. From 8c6a707558dcde9a48e722cb5562f8b24ca3d3a1 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 05:45:35 -0800 Subject: [PATCH 12/17] Tests: a key that ends a wait checks that the tap and the key both ran, in order The test now records the undo steps of a swap tap on X and of D, so a dropped tap fails it instead of leaving only the final tool to check. --- crates/ui-egui/src/shortcuts/hold_keys/tests.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/shortcuts/hold_keys/tests.rs b/crates/ui-egui/src/shortcuts/hold_keys/tests.rs index 86ee5f5c0c..a2406fcf83 100644 --- a/crates/ui-egui/src/shortcuts/hold_keys/tests.rs +++ b/crates/ui-egui/src/shortcuts/hold_keys/tests.rs @@ -294,17 +294,22 @@ fn turning_hold_shortcuts_off_ends_the_wait() { /// first. #[test] fn another_key_ends_the_wait_and_runs_after_it() { - let mut app = erolka_x(true); + let (swap, default) = (label("paint.swap"), label("paint.default")); + let mut app = swap_on_x(); + app.select_tool("selection"); let keys = Keyboard::new(); keys.press(&mut app, 0.0, Key::P, "p"); assert_eq!(app.session.tool_id(), "pen", "P runs on its press"); keys.release(&mut app, 0.05, Key::P); + let n = steps(&app, 0).len(); keys.press(&mut app, 0.1, Key::X, "x"); - keys.press(&mut app, 0.2, Key::V, "v"); - assert_eq!(app.session.tool_id(), "selection", "X's tap (Eyedropper) ran, then V (Selection)"); - assert_eq!(fill(&app), "#ff0000"); + assert_eq!(steps(&app, n), Vec::::new(), "X waits"); + keys.press(&mut app, 0.2, Key::D, "d"); + assert_eq!(steps(&app, n), [swap.clone(), default.clone()], "X's tap ran, then D"); keys.release(&mut app, 0.3, Key::X); - assert_eq!(app.session.tool_id(), "selection", "the release of X runs nothing more"); + keys.release(&mut app, 0.35, Key::D); + assert_eq!(steps(&app, n), [swap, default], "the release of X runs nothing more"); + assert_eq!(selected(&app), 1, "and no hold"); } /// The labels of the document's undo steps after the first `from`. From e6bf84050a6a72a86141842bb7f348ab44d98e4d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 07:04:55 -0800 Subject: [PATCH 13/17] Preferences: the description line has sentences for Hold Shortcuts and its delay General's description line now shows a sentence for Hold Shortcuts and for Hold Shortcut Delay, with a row in every catalog, as main requires for each General setting. --- crates/ui-egui/src/i18n/bg.tsv | 2 ++ crates/ui-egui/src/i18n/bs.tsv | 2 ++ crates/ui-egui/src/i18n/ca.tsv | 2 ++ crates/ui-egui/src/i18n/cs.tsv | 2 ++ crates/ui-egui/src/i18n/da.tsv | 2 ++ crates/ui-egui/src/i18n/de.tsv | 2 ++ crates/ui-egui/src/i18n/el.tsv | 2 ++ crates/ui-egui/src/i18n/es.tsv | 2 ++ crates/ui-egui/src/i18n/fi.tsv | 2 ++ crates/ui-egui/src/i18n/fr.tsv | 2 ++ crates/ui-egui/src/i18n/gu.tsv | 2 ++ crates/ui-egui/src/i18n/hi.tsv | 2 ++ crates/ui-egui/src/i18n/hu.tsv | 2 ++ crates/ui-egui/src/i18n/id.tsv | 2 ++ crates/ui-egui/src/i18n/it.tsv | 2 ++ crates/ui-egui/src/i18n/ja.tsv | 2 ++ crates/ui-egui/src/i18n/ka.tsv | 2 ++ crates/ui-egui/src/i18n/ko.tsv | 2 ++ crates/ui-egui/src/i18n/nl.tsv | 2 ++ crates/ui-egui/src/i18n/pl.tsv | 2 ++ crates/ui-egui/src/i18n/pt-br.tsv | 2 ++ crates/ui-egui/src/i18n/ru.tsv | 2 ++ crates/ui-egui/src/i18n/sv.tsv | 2 ++ crates/ui-egui/src/i18n/tr.tsv | 2 ++ crates/ui-egui/src/i18n/uk.tsv | 2 ++ crates/ui-egui/src/i18n/vi.tsv | 2 ++ crates/ui-egui/src/i18n/zh-hans.tsv | 2 ++ crates/ui-egui/src/i18n/zh-hant.tsv | 2 ++ crates/ui-egui/src/prefs_dialog/descriptions.rs | 2 ++ 29 files changed, 58 insertions(+) diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index 456f1c2f9c..50aee8d56b 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -3015,6 +3015,8 @@ digits Malayalam Малаялам The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. Колелцето на мишката с натиснат Cmd/Ctrl превърта платното настрани. Dragging sideways on a numeric field's label changes the field's value. Влаченето настрани върху етикета на числово поле променя стойността на полето. A two-finger rotate gesture on a trackpad rotates the canvas view. Жест за завъртане с два пръста върху тъчпад завърта изгледа на платното. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. Задържането на клавиш изпълнява инструмента или командата от колоната „Задръжте“ в „Клавишни комбинации“; краткото натискане изпълнява обичайната му комбинация. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. Колко секунди трябва да се задържи клавиш, преди вместо обичайната му комбинация да се изпълни комбинацията му със задържане. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. Задържането на клавишната комбинация на инструмент го избира, докато я пуснете, а след това отново се избира предишният инструмент. Shows the bounding box while you move the selection or draw a shape. Показва ограничителната рамка, докато премествате селекцията или рисувате форма. Create Trim Marks draws Japanese-style marks instead of Roman ones. „Създаване на режещи знаци“ рисува знаци в японски стил вместо в римски. diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index 978e396bfa..119fcdbbdf 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -4452,6 +4452,8 @@ font-technology Variable Varijabilni The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. Točkić miša uz pritisnut Cmd/Ctrl pomjera platno u stranu. Dragging sideways on a numeric field's label changes the field's value. Prevlačenje u stranu po oznaci brojčanog polja mijenja vrijednost polja. A two-finger rotate gesture on a trackpad rotates the canvas view. Pokret rotacije s dva prsta na dodirnoj podlozi rotira prikaz platna. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. Držanje tipke pokreće alat ili naredbu iz njene kolone „Zadrži“ u Prečicama na tastaturi; kratki pritisak pokreće njenu uobičajenu prečicu. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. Koliko sekundi tipka mora biti pritisnuta prije nego što se umjesto uobičajene prečice pokrene njena prečica zadržavanjem. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. Držanje prečice alata bira taj alat dok je ne pustite, a zatim se ponovo bira prethodni alat. Shows the bounding box while you move the selection or draw a shape. Prikazuje granični okvir dok pomjerate odabir ili crtate oblik. Create Trim Marks draws Japanese-style marks instead of Roman ones. Kreiraj oznake za obrezivanje crta oznake u japanskom stilu umjesto rimskih. diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index 796323f63e..18d31cd0e8 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -3845,6 +3845,8 @@ digits Malayalam Malaiàlam The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. La roda del ratolí amb Cmd/Ctrl premut desplaça el llenç en horitzontal. Dragging sideways on a numeric field's label changes the field's value. Arrossegar en horitzontal sobre l’etiqueta d’un camp numèric canvia el valor del camp. A two-finger rotate gesture on a trackpad rotates the canvas view. Un gest de rotació amb dos dits al trackpad gira la vista del llenç. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. Mantenir premuda una tecla executa l’eina o l’ordre de la seva columna Mantén a Dreceres de teclat; una pulsació breu executa la seva drecera habitual. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. Quants segons cal mantenir premuda una tecla perquè s’executi la seva drecera de pulsació llarga en lloc de la drecera habitual. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. Mantenir premuda la drecera d’una eina la tria fins que la deixeu anar, i després es torna a triar l’eina anterior. Shows the bounding box while you move the selection or draw a shape. Mostra el quadre delimitador mentre moveu la selecció o dibuixeu una forma. Create Trim Marks draws Japanese-style marks instead of Roman ones. Crea marques de retall dibuixa marques d’estil japonès en lloc de romanes. diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index fd48e6ecf8..263f476165 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -4556,6 +4556,8 @@ font-technology Variable Variabilní The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. Kolečko myši s podrženou klávesou Cmd/Ctrl posouvá plátno do stran. Dragging sideways on a numeric field's label changes the field's value. Tažení do stran po popisku číselného pole mění hodnotu pole. A two-finger rotate gesture on a trackpad rotates the canvas view. Gesto otočení dvěma prsty na trackpadu otáčí zobrazení plátna. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. Podržení klávesy spustí nástroj nebo příkaz ze sloupce Podržení v Klávesových zkratkách; krátký stisk spustí její obvyklou zkratku. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. Jak dlouho v sekundách je nutné klávesu podržet, než se místo obvyklé zkratky spustí její zkratka podržením. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. Podržení zkratky nástroje vybere nástroj, dokud ji nepustíte, a pak se znovu vybere předchozí nástroj. Shows the bounding box while you move the selection or draw a shape. Zobrazí ohraničovací rámeček, když přesouváte výběr nebo kreslíte tvar. Create Trim Marks draws Japanese-style marks instead of Roman ones. Vytvořit značky ořezu nakreslí značky v japonském stylu místo římských. diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 8c55a88674..2b565218f7 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -6955,6 +6955,8 @@ font-technology Variable Variable The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. Musehjulet med Cmd/Ctrl holdt nede ruller lærredet sidelæns. Dragging sideways on a numeric field's label changes the field's value. Når du trækker sidelæns på et talfelts etiket, ændres feltets værdi. A two-finger rotate gesture on a trackpad rotates the canvas view. En rotationsbevægelse med to fingre på en pegeplade roterer visningen af lærredet. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. Når du holder en tast nede, køres værktøjet eller kommandoen i dens Hold-kolonne i Tastaturgenveje; et kort tryk kører dens sædvanlige genvej. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. Hvor mange sekunder en tast skal holdes nede, før dens holdegenvej køres i stedet for dens sædvanlige genvej. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. Når du holder et værktøjs genvejstast nede, er værktøjet valgt, indtil du slipper, og derefter vælges det forrige værktøj igen. Shows the bounding box while you move the selection or draw a shape. Viser afgrænsningsboksen, mens du flytter markeringen eller tegner en form. Create Trim Marks draws Japanese-style marks instead of Roman ones. Opret beskæringsmærker tegner mærker i japansk stil i stedet for romerske. diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index db775c9948..98b4343eab 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -3067,6 +3067,8 @@ digits Malayalam Malayalam The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. Mit gedrückter Befehls-/Strg-Taste scrollt das Mausrad die Arbeitsfläche seitwärts. Dragging sideways on a numeric field's label changes the field's value. Seitliches Ziehen auf der Beschriftung eines Zahlenfelds ändert den Wert des Felds. A two-finger rotate gesture on a trackpad rotates the canvas view. Eine Drehgeste mit zwei Fingern auf einem Trackpad dreht die Ansicht der Arbeitsfläche. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. Halten Sie eine Taste, wird das Werkzeug oder der Befehl aus ihrer Spalte „Halten“ unter „Tastaturbefehle“ ausgeführt; ein kurzer Druck führt ihren üblichen Tastaturbefehl aus. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. Wie viele Sekunden eine Taste gehalten werden muss, bevor statt ihres üblichen Tastaturbefehls ihr Halte-Tastaturbefehl ausgeführt wird. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. Solange Sie das Tastaturkürzel eines Werkzeugs gedrückt halten, ist dieses Werkzeug gewählt; danach wird wieder das vorherige gewählt. Shows the bounding box while you move the selection or draw a shape. Zeigt den Begrenzungsrahmen an, während Sie die Auswahl verschieben oder eine Form zeichnen. Create Trim Marks draws Japanese-style marks instead of Roman ones. „Schnittmarken erstellen“ zeichnet japanische statt römische Marken. diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index b0b9fa49c4..00ec0c4ff6 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -3885,6 +3885,8 @@ digits Malayalam Μαλαγιάλαμ The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. Ο τροχός του ποντικιού με πατημένο το Cmd/Ctrl κυλά τον καμβά οριζόντια. Dragging sideways on a numeric field's label changes the field's value. Η μεταφορά προς τα πλάγια πάνω στην ετικέτα ενός αριθμητικού πεδίου αλλάζει την τιμή του πεδίου. A two-finger rotate gesture on a trackpad rotates the canvas view. Μια κίνηση περιστροφής με δύο δάχτυλα σε επιφάνεια αφής περιστρέφει την προβολή του καμβά. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. Το παρατεταμένο πάτημα ενός πλήκτρου εκτελεί το εργαλείο ή την εντολή της στήλης «Κρατήστε πατημένο» στις Συντομεύσεις πληκτρολογίου· ένα σύντομο πάτημα εκτελεί τη συνηθισμένη συντόμευσή του. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. Πόσα δευτερόλεπτα πρέπει να μένει πατημένο ένα πλήκτρο πριν εκτελεστεί η συντόμευση παρατεταμένου πατήματος αντί για τη συνηθισμένη συντόμευσή του. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. Όσο κρατάτε πατημένη τη συντόμευση ενός εργαλείου, το εργαλείο είναι επιλεγμένο, και μετά επιλέγεται ξανά το προηγούμενο εργαλείο. Shows the bounding box while you move the selection or draw a shape. Εμφανίζει το πλαίσιο οριοθέτησης όσο μετακινείτε την επιλογή ή σχεδιάζετε ένα σχήμα. Create Trim Marks draws Japanese-style marks instead of Roman ones. Η Δημιουργία σημαδιών ξακρίσματος σχεδιάζει σημάδια ιαπωνικού τύπου αντί για ρωμαϊκά. diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index bd977fac3d..f0789457eb 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -3105,6 +3105,8 @@ digits Malayalam Malayálam The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. La rueda del mouse con Cmd/Ctrl pulsado desplaza el lienzo en horizontal. Dragging sideways on a numeric field's label changes the field's value. Arrastrar en horizontal sobre la etiqueta de un campo numérico cambia el valor del campo. A two-finger rotate gesture on a trackpad rotates the canvas view. Un gesto de giro con dos dedos en un trackpad gira la vista del lienzo. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. Mantener pulsada una tecla ejecuta la herramienta o el comando de su columna Mantener pulsado en Métodos abreviados de teclado; una pulsación breve ejecuta su método abreviado habitual. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. Cuántos segundos hay que mantener pulsada una tecla para que se ejecute su método abreviado de pulsación larga en lugar del habitual. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. Mantener pulsado el atajo de una herramienta la elige hasta que lo suelta, y después vuelve a elegirse la herramienta anterior. Shows the bounding box while you move the selection or draw a shape. Muestra el cuadro delimitador mientras mueve la selección o dibuja una forma. Create Trim Marks draws Japanese-style marks instead of Roman ones. Crear marcas de recorte dibuja marcas de estilo japonés en lugar de romanas. diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index 1c7caa141a..7862c201b4 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -4475,6 +4475,8 @@ font-technology Variable Muuttuvat The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. Hiiren rulla vierittää piirtopintaa sivuttain, kun Cmd/Ctrl on painettuna. Dragging sideways on a numeric field's label changes the field's value. Numerokentän nimiön vetäminen sivuttain muuttaa kentän arvoa. A two-finger rotate gesture on a trackpad rotates the canvas view. Kahden sormen kiertoele kosketuslevyllä kiertää piirtopinnan näkymää. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. Näppäimen pitäminen painettuna suorittaa työkalun tai komennon sen Pidä pohjassa -sarakkeesta Pikanäppäimissä; lyhyt painallus suorittaa sen tavallisen pikanäppäimen. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. Kuinka monta sekuntia näppäintä on pidettävä painettuna, ennen kuin tavallisen pikanäppäimen sijaan suoritetaan sen pitkän painalluksen pikanäppäin. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. Työkalun pikanäppäimen pitäminen painettuna valitsee työkalun, kunnes päästät irti, ja sitten edellinen työkalu valitaan uudelleen. Shows the bounding box while you move the selection or draw a shape. Näyttää rajausruudun, kun siirrät valintaa tai piirrät muotoa. Create Trim Marks draws Japanese-style marks instead of Roman ones. Luo leikkuumerkit piirtää japanilaistyyliset merkit roomalaisten sijaan. diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 5da3445561..16fc1f2e4f 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -3093,6 +3093,8 @@ digits Malayalam Malayalam The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. La molette de la souris avec Cmd/Ctrl enfoncée fait défiler la zone de travail latéralement. Dragging sideways on a numeric field's label changes the field's value. Faire glisser latéralement le libellé d’un champ numérique modifie la valeur du champ. A two-finger rotate gesture on a trackpad rotates the canvas view. Un geste de rotation à deux doigts sur un pavé tactile fait pivoter la vue de la zone de travail. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. Maintenir une touche exécute l’outil ou la commande de sa colonne Maintenir dans Raccourcis clavier. Un appui bref exécute son raccourci habituel. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. Durée, en secondes, pendant laquelle une touche doit être maintenue pour que son raccourci de maintien s’exécute à la place de son raccourci habituel. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. Maintenir le raccourci d’un outil choisit cet outil jusqu’à ce que vous le relâchiez, puis l’outil précédent est de nouveau choisi. Shows the bounding box while you move the selection or draw a shape. Affiche le cadre de sélection pendant que vous déplacez la sélection ou dessinez une forme. Create Trim Marks draws Japanese-style marks instead of Roman ones. Créer des traits de coupe dessine des traits de style japonais au lieu de traits romains. diff --git a/crates/ui-egui/src/i18n/gu.tsv b/crates/ui-egui/src/i18n/gu.tsv index 880fe97eae..24bb9714d3 100644 --- a/crates/ui-egui/src/i18n/gu.tsv +++ b/crates/ui-egui/src/i18n/gu.tsv @@ -3179,6 +3179,8 @@ The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. Cmd/Ctrl દબાવી રાખીને માઉસ વ્હીલ ફેરવવાથી કેનવાસ બાજુમાં સ્ક્રોલ થાય છે. Dragging sideways on a numeric field's label changes the field's value. સંખ્યાત્મક ફીલ્ડના લેબલ પર બાજુમાં ખેંચવાથી ફીલ્ડનું મૂલ્ય બદલાય છે. A two-finger rotate gesture on a trackpad rotates the canvas view. ટ્રેકપેડ પર બે આંગળીથી ફેરવવાનો હાવભાવ કેનવાસનું દૃશ્ય ફેરવે છે. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. કી દબાવી રાખવાથી કીબોર્ડ શૉર્ટકટમાં તેની હોલ્ડ કૉલમનું ટૂલ અથવા કમાન્ડ ચાલે છે; ટૂંકું દબાણ તેનો સામાન્ય શોર્ટકટ ચલાવે છે. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. કીનો હોલ્ડ શોર્ટકટ તેના સામાન્ય શોર્ટકટને બદલે ચાલે તે પહેલાં કીને કેટલી સેકન્ડ દબાવી રાખવી પડે. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. ટૂલની શોર્ટકટ કી દબાવી રાખવાથી છોડો ત્યાં સુધી તે ટૂલ પસંદ રહે છે, પછી અગાઉનું ટૂલ ફરી પસંદ થાય છે. Shows the bounding box while you move the selection or draw a shape. તમે પસંદગી ખસેડો કે આકાર દોરો ત્યારે બાઉન્ડિંગ બોક્સ બતાવે છે. Create Trim Marks draws Japanese-style marks instead of Roman ones. ટ્રિમ માર્ક્સ બનાવો રોમન ને બદલે જાપાની શૈલીના ચિહ્નો દોરે છે. diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index ba969e3f7a..34ed704661 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -4215,6 +4215,8 @@ antiAlias Sharp शार्प The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. Cmd/Ctrl दबाकर माउस व्हील घुमाने से कैनवास बगल की ओर स्क्रॉल होता है। Dragging sideways on a numeric field's label changes the field's value. किसी संख्या वाले फ़ील्ड के लेबल पर बगल की ओर ड्रैग करने से फ़ील्ड का मान बदलता है। A two-finger rotate gesture on a trackpad rotates the canvas view. ट्रैकपैड पर दो उंगलियों से घुमाने का जेस्चर कैनवास के व्यू को घुमाता है। + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. किसी कुंजी को दबाए रखने पर कीबोर्ड शॉर्टकट में उसके होल्ड कॉलम का टूल या कमांड चलता है; जल्दी दबाने पर उसका सामान्य शॉर्टकट चलता है। + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. किसी कुंजी को कितने सेकंड दबाए रखना होगा, ताकि उसके सामान्य शॉर्टकट के बजाय उसका होल्ड शॉर्टकट चले। Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. किसी टूल की शॉर्टकट कुंजी दबाए रखने पर वह टूल छोड़ने तक चुना रहता है, फिर पिछला टूल दोबारा चुना जाता है। Shows the bounding box while you move the selection or draw a shape. सिलेक्शन खिसकाते या आकार ड्रॉ करते समय बाउंडिंग बॉक्स दिखाता है। Create Trim Marks draws Japanese-style marks instead of Roman ones. ट्रिम मार्क्स बनाएं रोमन की जगह जापानी शैली के निशान ड्रॉ करता है। diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index acbe927e9f..3d2cdc1e8c 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -3686,6 +3686,8 @@ mark-style Japanese Japán The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. Az egérgörgő lenyomott Cmd/Ctrl billentyűvel oldalirányban görgeti a vásznat. Dragging sideways on a numeric field's label changes the field's value. Egy számmező címkéjén oldalirányban húzva módosul a mező értéke. A two-finger rotate gesture on a trackpad rotates the canvas view. Az érintőpadon végzett kétujjas forgató kézmozdulat elforgatja a vászon nézetét. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. Egy billentyű nyomva tartása a Billentyűparancsok Nyomva tartás oszlopában lévő eszközt vagy parancsot futtatja; egy rövid lenyomás a szokásos billentyűparancsát futtatja. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. Hány másodpercig kell nyomva tartani egy billentyűt, hogy a szokásos billentyűparancsa helyett a nyomva tartásos billentyűparancsa fusson. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. Egy eszköz billentyűparancsát lenyomva tartva az eszköz a felengedésig ki van választva, utána ismét az előző eszköz lesz kiválasztva. Shows the bounding box while you move the selection or draw a shape. Megjeleníti a befoglaló keretet, miközben a kijelölést mozgatja vagy alakzatot rajzol. Create Trim Marks draws Japanese-style marks instead of Roman ones. A Vágójelek létrehozása római helyett japán stílusú jeleket rajzol. diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 4cb906773e..3105753e9d 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -4207,6 +4207,8 @@ font-technology Variable Variabel The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. Roda mouse dengan Cmd/Ctrl ditahan menggulir kanvas ke samping. Dragging sideways on a numeric field's label changes the field's value. Menyeret ke samping pada label bidang angka mengubah nilai bidang itu. A two-finger rotate gesture on a trackpad rotates the canvas view. Gerakan putar dua jari pada trackpad memutar tampilan kanvas. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. Menahan tombol menjalankan alat atau perintah di kolom Tahan pada Pintasan papan ketik; tekanan singkat menjalankan pintasan biasanya. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. Berapa detik tombol harus ditahan sebelum pintasan tahannya berjalan sebagai ganti pintasan biasanya. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. Menahan tombol pintasan alat memilih alat itu sampai Anda melepasnya, lalu alat sebelumnya dipilih lagi. Shows the bounding box while you move the selection or draw a shape. Menampilkan kotak pembatas saat Anda memindahkan seleksi atau menggambar bentuk. Create Trim Marks draws Japanese-style marks instead of Roman ones. Buat tanda potong menggambar tanda bergaya Jepang, bukan Romawi. diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 6da474e5b7..38036f2cc2 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -3148,6 +3148,8 @@ digits Malayalam Malayalam The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. La rotellina del mouse con Cmd/Ctrl premuto scorre l'area di lavoro in orizzontale. Dragging sideways on a numeric field's label changes the field's value. Trascinare in orizzontale sull'etichetta di un campo numerico ne cambia il valore. A two-finger rotate gesture on a trackpad rotates the canvas view. Un gesto di rotazione con due dita sul trackpad ruota la vista dell'area di lavoro. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. Tenere premuto un tasto esegue lo strumento o il comando della sua colonna Tieni premuto in Scelte rapide da tastiera; una pressione breve esegue la sua scorciatoia abituale. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. Per quanti secondi va tenuto premuto un tasto prima che venga eseguita la sua scorciatoia a pressione prolungata invece di quella abituale. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. Tenere premuta la scorciatoia di uno strumento lo sceglie finché non la rilasci, poi viene scelto di nuovo lo strumento precedente. Shows the bounding box while you move the selection or draw a shape. Mostra il riquadro di delimitazione mentre sposti la selezione o disegni una forma. Create Trim Marks draws Japanese-style marks instead of Roman ones. Crea segni di taglio disegna segni in stile giapponese invece di quelli romani. diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index fbd38a5e07..1344c21a5b 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -3125,6 +3125,8 @@ mark-style Japanese 日本式 The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. Cmd/Ctrl キーを押しながらマウスホイールを回すとカンバスを横にスクロールします。 Dragging sideways on a numeric field's label changes the field's value. 数値フィールドのラベルを横にドラッグすると、フィールドの値が変わります。 A two-finger rotate gesture on a trackpad rotates the canvas view. トラックパッドで 2 本指の回転ジェスチャーをすると、カンバスの表示が回転します。 + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. キーを長押しすると、キーボードショートカットの長押し列にあるツールまたはコマンドを実行します。短く押すと通常のショートカットを実行します。 + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. 通常のショートカットの代わりに長押しショートカットを実行するまで、キーを押し続ける秒数です。 Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. ツールのショートカットキーを押している間はそのツールを選び、離すと前のツールに戻ります。 Shows the bounding box while you move the selection or draw a shape. 選択範囲の移動中や図形の描画中にバウンディングボックスを表示します。 Create Trim Marks draws Japanese-style marks instead of Roman ones. トリムマークを作成で、西洋式ではなく日本式のトンボを描きます。 diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index bb93a48b3f..8c842c60e1 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -6273,6 +6273,8 @@ font-technology Variable ცვლადი The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. დაჭერილი Cmd/Ctrl-ით მაუსის ბორბალი ტილოს გვერდულად გადაახვევს. Dragging sideways on a numeric field's label changes the field's value. რიცხვითი ველის წარწერაზე გვერდულად გადათრევა ველის მნიშვნელობას ცვლის. A two-finger rotate gesture on a trackpad rotates the canvas view. ტრეკპადზე ორი თითით მობრუნების ჟესტი ტილოს ხედს აბრუნებს. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. კლავიშის ხანგრძლივი დაჭერა უშვებს ხელსაწყოს ან ბრძანებას კლავიატურის მალსახმობების დაჭერის სვეტიდან; მოკლე დაჭერა უშვებს მის ჩვეულ მალსახმობს. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. რამდენი წამი უნდა იყოს კლავიში დაჭერილი, სანამ ჩვეული მალსახმობის ნაცვლად მისი ხანგრძლივი დაჭერის მალსახმობი გაეშვება. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. ხელსაწყოს მალსახმობი კლავიშის დაჭერით ხელსაწყო არჩეულია მის აშვებამდე, შემდეგ კი ისევ წინა ხელსაწყო აირჩევა. Shows the bounding box while you move the selection or draw a shape. აჩვენებს შემომსაზღვრელ ჩარჩოს, სანამ მონიშნულს გადაადგილებთ ან ფიგურას ხატავთ. Create Trim Marks draws Japanese-style marks instead of Roman ones. ჭრის ნიშნების შექმნა რომაულის ნაცვლად იაპონური სტილის ნიშნებს ხატავს. diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 71acb3c37f..1acd895bde 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -3114,6 +3114,8 @@ mark-style Japanese 일본식 The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. Cmd/Ctrl 키를 누른 채 마우스 휠을 돌리면 캔버스가 가로로 스크롤됩니다. Dragging sideways on a numeric field's label changes the field's value. 숫자 필드의 레이블을 옆으로 드래그하면 필드 값이 바뀝니다. A two-finger rotate gesture on a trackpad rotates the canvas view. 트랙패드에서 두 손가락으로 회전하는 동작을 하면 캔버스 보기가 회전합니다. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. 키를 누르고 있으면 키보드 단축키의 누르고 있기 열에 있는 도구나 명령이 실행되고, 짧게 누르면 평소 단축키가 실행됩니다. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. 평소 단축키 대신 길게 누르기 단축키가 실행되기 전까지 키를 누르고 있어야 하는 시간(초)입니다. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. 도구의 바로 가기 키를 누르고 있는 동안 그 도구가 선택되고, 키를 놓으면 이전 도구가 다시 선택됩니다. Shows the bounding box while you move the selection or draw a shape. 선택 영역을 이동하거나 모양을 그리는 동안 테두리 상자를 표시합니다. Create Trim Marks draws Japanese-style marks instead of Roman ones. 트림 마크 만들기에서 서양식 대신 일본식 표시를 그립니다. diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 96c20d9809..41aa245899 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -4829,6 +4829,8 @@ font-technology Variable Variabel The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. Het muiswiel met Cmd/Ctrl ingedrukt schuift het canvas zijwaarts. Dragging sideways on a numeric field's label changes the field's value. Zijwaarts slepen over het label van een numeriek veld wijzigt de waarde van het veld. A two-finger rotate gesture on a trackpad rotates the canvas view. Een draaigebaar met twee vingers op een trackpad draait de weergave van het canvas. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. Als u een toets vasthoudt, wordt het gereedschap of de opdracht uit de kolom Houd in Sneltoetsen uitgevoerd; kort drukken voert de gewone sneltoets uit. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. Hoeveel seconden u een toets moet vasthouden voordat de vasthoudsneltoets wordt uitgevoerd in plaats van de gewone sneltoets. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. Als u de sneltoets van een gereedschap ingedrukt houdt, is dat gereedschap gekozen tot u loslaat, en daarna wordt het vorige gereedschap weer gekozen. Shows the bounding box while you move the selection or draw a shape. Toont het begrenzingskader terwijl u de selectie verplaatst of een vorm tekent. Create Trim Marks draws Japanese-style marks instead of Roman ones. Afsnijtekens maken tekent tekens in Japanse stijl in plaats van Romeinse. diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index c71c172e87..7b8358ef06 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -4397,6 +4397,8 @@ font-technology Variable Zmienne The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. Kółko myszy z wciśniętym Cmd/Ctrl przewija obszar roboczy w poziomie. Dragging sideways on a numeric field's label changes the field's value. Przeciąganie w bok po etykiecie pola liczbowego zmienia wartość pola. A two-finger rotate gesture on a trackpad rotates the canvas view. Gest obrotu dwoma palcami na gładziku obraca widok obszaru roboczego. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. Przytrzymanie klawisza uruchamia narzędzie lub polecenie z jego kolumny Przytrzymaj w Skrótach klawiaturowych; krótkie naciśnięcie uruchamia jego zwykły skrót. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. Ile sekund trzeba przytrzymać klawisz, zanim zamiast zwykłego skrótu zostanie uruchomiony jego skrót przytrzymania. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. Przytrzymanie skrótu narzędzia wybiera je do momentu puszczenia klawisza, a potem ponownie wybierane jest poprzednie narzędzie. Shows the bounding box while you move the selection or draw a shape. Pokazuje obwiednię podczas przesuwania zaznaczenia lub rysowania kształtu. Create Trim Marks draws Japanese-style marks instead of Roman ones. Utwórz znaczniki przycięcia rysuje znaczniki w stylu japońskim zamiast rzymskich. diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index c55d25b29c..bc5242d47f 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -2597,6 +2597,8 @@ digits Malayalam Malaiala The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. A roda do mouse com Cmd/Ctrl pressionado rola a tela para os lados. Dragging sideways on a numeric field's label changes the field's value. Arrastar para os lados sobre o rótulo de um campo numérico muda o valor do campo. A two-finger rotate gesture on a trackpad rotates the canvas view. Um gesto de rotação com dois dedos no trackpad gira a visualização da tela. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. Manter uma tecla pressionada executa a ferramenta ou o comando da coluna Manter pressionado em Atalhos de Teclado; um toque rápido executa o atalho habitual. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. Quantos segundos uma tecla precisa ficar pressionada até que seu atalho de pressionamento longo seja executado no lugar do atalho habitual. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. Manter pressionado o atalho de uma ferramenta a escolhe até você soltar, e então a ferramenta anterior é escolhida de novo. Shows the bounding box while you move the selection or draw a shape. Mostra a caixa delimitadora enquanto você move a seleção ou desenha uma forma. Create Trim Marks draws Japanese-style marks instead of Roman ones. Criar Marcas de Corte desenha marcas no estilo japonês em vez de romanas. diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 8034801e32..69a9229951 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -3135,6 +3135,8 @@ digits Malayalam Малаялам The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. Колесо мыши с нажатой Cmd/Ctrl прокручивает холст по горизонтали. Dragging sideways on a numeric field's label changes the field's value. Перетаскивание по подписи числового поля в сторону меняет значение поля. A two-finger rotate gesture on a trackpad rotates the canvas view. Жест поворота двумя пальцами на трекпаде поворачивает вид холста. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. Удержание клавиши запускает инструмент или команду из её столбца «Удерживать» в «Сочетаниях клавиш»; короткое нажатие запускает её обычное сочетание. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. Сколько секунд нужно удерживать клавишу, прежде чем вместо её обычного сочетания сработает сочетание удержания. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. Пока вы удерживаете клавишу инструмента, он остаётся выбранным, а после отпускания снова выбирается предыдущий инструмент. Shows the bounding box while you move the selection or draw a shape. Показывает ограничивающую рамку, пока вы перемещаете выделение или рисуете фигуру. Create Trim Marks draws Japanese-style marks instead of Roman ones. «Создать метки подрезки» рисует метки в японском стиле вместо западных. diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index df718765da..1eb7de86af 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -3035,6 +3035,8 @@ digits Malayalam Malayalam The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. Mushjulet med Cmd/Ctrl nedtryckt rullar arbetsytan i sidled. Dragging sideways on a numeric field's label changes the field's value. Att dra i sidled på ett sifferfälts etikett ändrar fältets värde. A two-finger rotate gesture on a trackpad rotates the canvas view. En rotationsgest med två fingrar på en styrplatta roterar arbetsytans vy. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. Om du håller ned en tangent körs verktyget eller kommandot i dess Håll-kolumn i Kortkommandon; ett kort tryck kör dess vanliga kortkommando. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. Hur många sekunder en tangent måste hållas ned innan dess hållkortkommando körs i stället för dess vanliga kortkommando. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. När du håller ned ett verktygs kortkommando är verktyget valt tills du släpper, och sedan väljs det föregående verktyget igen. Shows the bounding box while you move the selection or draw a shape. Visar avgränsningsramen medan du flyttar markeringen eller ritar en form. Create Trim Marks draws Japanese-style marks instead of Roman ones. Skapa skärmärken ritar märken i japansk stil i stället för romerska. diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index e812704fd8..84d44062d5 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -2872,6 +2872,8 @@ digits Malayalam Malayalam The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. Cmd/Ctrl basılıyken fare tekerleği tuvali yana kaydırır. Dragging sideways on a numeric field's label changes the field's value. Sayısal bir alanın etiketi üzerinde yana sürüklemek alanın değerini değiştirir. A two-finger rotate gesture on a trackpad rotates the canvas view. İzleme dörtgeninde iki parmakla döndürme hareketi tuvalin görünümünü döndürür. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. Bir tuşu basılı tutmak, Klavye Kısayolları'ndaki Basılı tutun sütununda bulunan aracı veya komutu çalıştırır; kısa basış olağan kısayolunu çalıştırır. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. Olağan kısayolu yerine basılı tutma kısayolunun çalışması için bir tuşun kaç saniye basılı tutulması gerektiği. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. Bir aracın kısayol tuşunu basılı tutmak, tuşu bırakana kadar o aracı seçer, ardından önceki araç yeniden seçilir. Shows the bounding box while you move the selection or draw a shape. Seçimi taşırken veya bir şekil çizerken sınırlayıcı kutuyu gösterir. Create Trim Marks draws Japanese-style marks instead of Roman ones. Kesim İşaretleri Oluşturun, Roma tarzı yerine Japon tarzı işaretler çizer. diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index e6187a8dff..60aea700e0 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -3140,6 +3140,8 @@ digits Malayalam Малаялам The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. Колесо миші з натиснутою Cmd/Ctrl прокручує полотно по горизонталі. Dragging sideways on a numeric field's label changes the field's value. Перетягування вбік по підпису числового поля змінює значення поля. A two-finger rotate gesture on a trackpad rotates the canvas view. Жест обертання двома пальцями на трекпаді обертає вигляд полотна. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. Утримання клавіші запускає інструмент або команду з її стовпця «Утримувати» в «Поєднаннях клавіш»; коротке натискання запускає її звичайне поєднання. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. Скільки секунд потрібно утримувати клавішу, перш ніж замість її звичайного поєднання спрацює поєднання утримання. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. Поки ви утримуєте клавішу інструмента, його вибрано, а після відпускання знову вибирається попередній інструмент. Shows the bounding box while you move the selection or draw a shape. Показує обмежувальну рамку, поки ви переміщуєте виділення або малюєте фігуру. Create Trim Marks draws Japanese-style marks instead of Roman ones. «Створити мітки підрізування» малює мітки в японському стилі замість західних. diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index aec4006a04..c44d107243 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -3455,6 +3455,8 @@ mark-style Japanese Kiểu Nhật The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. Con lăn chuột kèm giữ Cmd/Ctrl cuộn khung vẽ sang ngang. Dragging sideways on a numeric field's label changes the field's value. Kéo sang ngang trên nhãn của một trường số sẽ thay đổi giá trị của trường. A two-finger rotate gesture on a trackpad rotates the canvas view. Cử chỉ xoay bằng hai ngón trên bàn di chuột sẽ xoay khung nhìn của khung vẽ. + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. Giữ một phím sẽ chạy công cụ hoặc lệnh trong cột Giữ của Phím tắt; nhấn nhanh sẽ chạy phím tắt thông thường của phím đó. + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. Số giây phải giữ một phím trước khi phím tắt nhấn giữ của nó chạy thay cho phím tắt thông thường. Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. Giữ phím tắt của một công cụ sẽ chọn công cụ đó cho đến khi bạn thả ra, rồi công cụ trước đó được chọn lại. Shows the bounding box while you move the selection or draw a shape. Hiển thị hộp giới hạn khi bạn di chuyển vùng chọn hoặc vẽ một hình. Create Trim Marks draws Japanese-style marks instead of Roman ones. Tạo dấu cắt xén vẽ dấu kiểu Nhật thay cho kiểu La Mã. diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 9f824ca033..d8e06cd32d 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -2999,6 +2999,8 @@ digits Malayalam 马拉雅拉姆数字 The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. 按住 Cmd/Ctrl 滚动鼠标滚轮会横向滚动画布。 Dragging sideways on a numeric field's label changes the field's value. 在数值字段的标签上横向拖动可更改字段的值。 A two-finger rotate gesture on a trackpad rotates the canvas view. 在触控板上用双指旋转手势可旋转画布视图。 + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. 按住某个键会运行键盘快捷键中其按住列的工具或命令;快速按下则运行其常规快捷键。 + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. 按住某个键多少秒后,运行其按住快捷键而不是常规快捷键。 Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. 按住工具的快捷键时选择该工具,松开后重新选择之前的工具。 Shows the bounding box while you move the selection or draw a shape. 移动所选对象或绘制形状时显示定界框。 Create Trim Marks draws Japanese-style marks instead of Roman ones. 创建裁切标记绘制日式标记,而不是西式标记。 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 5404f2e9fd..5a3624ed8f 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -4283,6 +4283,8 @@ digits Malayalam 馬來亞拉姆數字 The mouse wheel with Cmd/Ctrl held scrolls the canvas sideways. 按住 Cmd/Ctrl 捲動滑鼠滾輪會橫向捲動畫布。 Dragging sideways on a numeric field's label changes the field's value. 在數值欄位的標籤上橫向拖曳可變更欄位的值。 A two-finger rotate gesture on a trackpad rotates the canvas view. 在觸控式軌跡板上以雙指旋轉手勢可旋轉畫布檢視。 + Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut. 按住某個鍵會執行鍵盤快速鍵中其按住欄的工具或命令;快速按下則執行其一般快速鍵。 + How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut. 按住某個鍵多少秒後,執行其按住快速鍵而不是一般快速鍵。 Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again. 按住工具的快速鍵時選擇該工具,放開後重新選擇之前的工具。 Shows the bounding box while you move the selection or draw a shape. 移動選取範圍或繪製形狀時顯示邊框。 Create Trim Marks draws Japanese-style marks instead of Roman ones. 建立剪裁標記繪製日式標記,而不是西式標記。 diff --git a/crates/ui-egui/src/prefs_dialog/descriptions.rs b/crates/ui-egui/src/prefs_dialog/descriptions.rs index eb8156f8dd..984597bdd8 100644 --- a/crates/ui-egui/src/prefs_dialog/descriptions.rs +++ b/crates/ui-egui/src/prefs_dialog/descriptions.rs @@ -40,6 +40,8 @@ pub(crate) const DESCRIPTIONS: &[(&str, &str)] = &[ ("scrubNumericFields", "Dragging sideways on a numeric field's label changes the field's value."), ("trackpadRotateView", "A two-finger rotate gesture on a trackpad rotates the canvas view."), ("holdToolKeys", "Holding a tool's shortcut key chooses the tool until you let go, and then the previous tool is chosen again."), + ("holdShortcuts", "Holding a key runs the tool or command in its Hold column in Keyboard Shortcuts; a quick press runs its usual shortcut."), + ("keyHoldDelay", "How long, in seconds, a key must be held before its hold shortcut runs instead of its usual shortcut."), ("boundingBoxWhileMovingAndDrawing", "Shows the bounding box while you move the selection or draw a shape."), ("japaneseCropMarks", "Create Trim Marks draws Japanese-style marks instead of Roman ones."), ("newArtBasic", "New art takes only the fill and stroke of the selection; off, it takes the selected object's whole appearance."), From c886ab1698d82fbca0cd3e3e187b38edb3473034 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 07:19:14 -0800 Subject: [PATCH 14/17] Shortcuts: a tool key before a hold key in one frame reaches its tool first When a key the active tool takes (E with the Extend Path tool) went down before a key with a hold shortcut that was pressed and let go in the same frame, the hold key's tap ran first. A tap that chose another tool then sent the earlier key to the new tool. The hold key now goes back to the frame in that case, as it does after a chord with Cmd, Ctrl or Alt, so both keys act in order as with Hold Shortcuts off. --- crates/ui-egui/src/shortcuts/hold_keys.rs | 35 ++++++++++++------- .../ui-egui/src/shortcuts/hold_keys/tests.rs | 21 +++++++++++ 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/crates/ui-egui/src/shortcuts/hold_keys.rs b/crates/ui-egui/src/shortcuts/hold_keys.rs index b504be57d8..2c6767fb77 100644 --- a/crates/ui-egui/src/shortcuts/hold_keys.rs +++ b/crates/ui-egui/src/shortcuts/hold_keys.rs @@ -208,12 +208,22 @@ fn tool_takes(app: &mut VectorcraftApp, key: Key, text: &str) -> bool { tool_key.is_some_and(|k| app.session.tool_claims_key(k, view)) } -/// Is there a press with Cmd, Ctrl or Alt before the event at `start` that no wait took? -fn chord_before(events: &[egui::Event], start: usize, taken: &[usize]) -> bool { - events.iter().enumerate().take(start).any(|(k, e)| { - !taken.contains(&k) - && matches!(e, egui::Event::Key { key, pressed: true, modifiers: m, .. } - if !super::is_modifier(*key) && (m.command || m.ctrl || m.alt || m.mac_cmd)) +/// Is there a press before the event at `start` that no wait took and that the frame handles: one +/// with Cmd, Ctrl or Alt, or one that typed a text of a key the active tool takes ([`tool_takes`])? +fn chord_before(app: &mut VectorcraftApp, events: &[egui::Event], typed_by: &[Option], start: usize, taken: &[usize]) -> bool { + let mut before = events.iter().enumerate().take(start).filter(|(k, _)| !taken.contains(k)); + before.any(|(k, e)| match e { + egui::Event::Key { key, pressed: true, modifiers: m, .. } if !super::is_modifier(*key) => { + m.command + || m.ctrl + || m.alt + || m.mac_cmd + || typed_by + .iter() + .enumerate() + .any(|(t, by)| *by == Some(k) && matches!(events.get(t), Some(egui::Event::Text(text)) if tool_takes(app, *key, text))) + } + _ => false, }) } @@ -269,7 +279,8 @@ fn run_typed_before( /// its text from the frame, with the key's repeats that follow in the frame and their text. When a /// wait that started in this frame also ends in it, the keys typed before its key run first /// ([`run_typed_before`]), so they act in the order they went down; after a chord with Cmd, Ctrl -/// or Alt before its key, the key goes back to the frame instead ([`chord_before`]). Then a wait +/// or Alt, or a key the active tool takes, before its key, the key goes back to the frame instead +/// ([`chord_before`]). Then a wait /// whose delay has passed with the key down runs the hold shortcut. True when a result opened a /// dialog or the palette: the rest of the frame's keys are dropped and no other shortcut runs. pub(super) fn intake(app: &mut VectorcraftApp, ctx: &egui::Context) -> bool { @@ -311,12 +322,12 @@ pub(super) fn intake(app: &mut VectorcraftApp, ctx: &egui::Context) -> bool { if let Some((hold, down)) = ended { let start = started.take(); // After a chord with Cmd, Ctrl or Alt pressed before it, which the frame's shortcuts - // run, the key goes back to the frame without waiting, so the frame handles it as it - // does with Hold Shortcuts off and its tap does not run before the chord. Its press, - // its repeats and their texts stay in the frame, and its later repeats reach later - // frames. + // run, or a key the active tool takes, the key goes back to the frame without + // waiting, so the frame handles it as it does with Hold Shortcuts off and its tap + // does not run before that key. Its press, its repeats and their texts stay in the + // frame, and its later repeats reach later frames. if let Some((start, before)) = start - && chord_before(&events, start, &taken) + && chord_before(app, &events, &typed_by, start, &taken) { app.hold_keys.pending = None; taken.truncate(before); diff --git a/crates/ui-egui/src/shortcuts/hold_keys/tests.rs b/crates/ui-egui/src/shortcuts/hold_keys/tests.rs index a2406fcf83..8502ef6091 100644 --- a/crates/ui-egui/src/shortcuts/hold_keys/tests.rs +++ b/crates/ui-egui/src/shortcuts/hold_keys/tests.rs @@ -424,6 +424,27 @@ fn a_chord_before_a_wait_ended_in_its_frame_runs_first() { assert!(app.hold_keys.pending.is_none()); } +/// A key the active tool takes (E with the Extend Path tool), pressed before a wait that starts and +/// ends in one frame, reaches the tool first: the key's tap, which chooses another tool, does not +/// run before it, and the frame acts as it does with Hold Shortcuts off. +#[test] +fn a_tool_key_before_a_wait_ended_in_its_frame_reaches_the_tool_first() { + let frame = |app: &mut VectorcraftApp| { + app.select_tool(vectorcraft_tools::addons::extend_path::ID); + let mut events = press(Key::E, "e", Modifiers::NONE); + events.extend(press(Key::X, "x", Modifiers::NONE)); + events.push(release(Key::X)); + Keyboard::new().frame(app, 0.0, events); + (app.session.tool_id().to_string(), fill(app)) + }; + let off = frame(&mut erolka_x(false)); + let mut app = erolka_x(true); + let on = frame(&mut app); + assert_eq!(on.0, "eyedropper", "X's tap chooses the Eyedropper after E reached the Extend Path tool"); + assert_eq!(on, off); + assert!(app.hold_keys.pending.is_none()); +} + /// After a command chord before a wait that starts and ends in one frame, the key's repeats in /// that frame and in later ones, and the text they type, reach the frame as with Hold Shortcuts /// off. From 553a31883f1da64c3e641fdef6a927ce512411ca Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 07:31:02 -0800 Subject: [PATCH 15/17] Shortcuts: the Keyboard Shortcuts search finds a row by its hold shortcut While Hold Shortcuts is on, typing a key in the search now finds the row whose Hold column shows it, as it finds a row by its shortcut. --- crates/ui-egui/src/shortcut_editor.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/shortcut_editor.rs b/crates/ui-egui/src/shortcut_editor.rs index b9bfe65546..ec5b94cdf1 100644 --- a/crates/ui-egui/src/shortcut_editor.rs +++ b/crates/ui-egui/src/shortcut_editor.rs @@ -1972,7 +1972,8 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) { Cow::Borrowed(_) => view.texts.get(i).cloned().flatten(), Cow::Owned(km) => dialog_shortcuts_with(km, &e.key, view.backtick.as_deref()), }; - if !q.is_empty() && !row_matches(e, &q, sc.as_deref()) { + let hold_text = if holds_on { hold_of(&holds, &e.key).map(|h| menus::pretty_shortcut(&h)) } else { None }; + if !q.is_empty() && !row_matches(e, &q, sc.as_deref()) && !hold_text.is_some_and(|h| h.to_lowercase().contains(&q)) { continue; } let row = ui.horizontal(|ui| { @@ -3783,6 +3784,25 @@ mod tests { assert!(texts.iter().any(|t| t.starts_with("A quick press")) && texts.iter().any(|t| t == "Tap"), "{texts:?}"); } + /// While Hold Shortcuts is on, the search finds a row by its hold shortcut as the Hold column + /// shows it; while it is off, the hold shortcut finds nothing. + #[test] + fn the_search_finds_a_row_by_its_hold_shortcut() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.run("shortcuts.set", json!({"id": "paint.swap", "hold": "Shift+;"})).unwrap(); + let hold = menus::pretty_shortcut("Shift+;").to_lowercase(); + let name = shown_name(&entry("paint.swap").unwrap()); + assert!(!name.to_lowercase().contains(&hold), "{name}"); + open(&mut app); + let d = app.ui.dialog.as_mut().unwrap(); + d.fields.insert("tab".into(), json!("menu")); + d.fields.insert("query".into(), json!(hold)); + assert!(!dialog_texts(&mut app).contains(&name), "off, the hold shortcut finds nothing"); + app.ui.dialog.as_mut().unwrap().fields.insert("holdShortcuts".into(), json!(true)); + let texts = dialog_texts(&mut app); + assert!(texts.contains(&name), "{name} in {texts:?}"); + } + /// A command that needs a value is listed in the editor once the user gives it a key, but the /// command search still leaves it out: a pick gives it no value. #[test] From 1ed9337e7893e72391273427033587e9d4999381 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 07:41:45 -0800 Subject: [PATCH 16/17] Shortcuts: a wait a dialog ends drops the key's repeat in the frame it is let go When a dialog or field took the keyboard while a key with a hold shortcut waited, and the next frame held both a repeat of the key and its release, the repeat and the text it typed reached the dialog. The frame that ends the wait now drops them too. --- crates/ui-egui/src/shortcuts/hold_keys.rs | 6 ++++-- .../ui-egui/src/shortcuts/hold_keys/tests.rs | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/shortcuts/hold_keys.rs b/crates/ui-egui/src/shortcuts/hold_keys.rs index 2c6767fb77..e5cbdc15e1 100644 --- a/crates/ui-egui/src/shortcuts/hold_keys.rs +++ b/crates/ui-egui/src/shortcuts/hold_keys.rs @@ -90,11 +90,13 @@ pub(super) fn guard(app: &mut VectorcraftApp, ctx: &egui::Context, focused: bool app.hold_keys.swallowed.retain(|s| s.viewport != viewport); return; } + let mut held: Vec<(Key, Option)> = app.hold_keys.swallowed.iter().filter(|s| s.viewport == viewport).map(|s| (s.key, s.physical)).collect(); + held.extend(app.hold_keys.pending.as_ref().filter(|p| p.viewport == viewport).map(|p| (p.key, p.physical))); + // A wait that ends here still drops this frame's repeats of its key, also when the frame lets + // the key go. if app.hold_keys.pending.as_ref().is_some_and(|p| p.viewport == viewport) && (blocked(app, ctx) || !app.session.prefs.hold_shortcuts) { cancel(app, ctx); } - let mut held: Vec<(Key, Option)> = app.hold_keys.swallowed.iter().filter(|s| s.viewport == viewport).map(|s| (s.key, s.physical)).collect(); - held.extend(app.hold_keys.pending.as_ref().filter(|p| p.viewport == viewport).map(|p| (p.key, p.physical))); if held.is_empty() { return; } diff --git a/crates/ui-egui/src/shortcuts/hold_keys/tests.rs b/crates/ui-egui/src/shortcuts/hold_keys/tests.rs index 8502ef6091..6afc2a0002 100644 --- a/crates/ui-egui/src/shortcuts/hold_keys/tests.rs +++ b/crates/ui-egui/src/shortcuts/hold_keys/tests.rs @@ -238,6 +238,25 @@ fn a_dialog_or_presentation_mode_ends_the_wait() { } } +/// A dialog opened while a key waits does not get the key's repeat, or the text it types, from the +/// frame that also lets the key go. +#[test] +fn a_dialog_that_ends_the_wait_gets_no_repeat_from_the_frame_of_the_release() { + let mut app = erolka_x(true); + let keys = Keyboard::new(); + keys.press(&mut app, 0.0, Key::X, "x"); + assert!(app.hold_keys.pending.is_some()); + app.ui.dialog = Some(crate::state::Dialog::new("preferences", json!({}))); + let mut events = press(Key::X, "x", Modifiers::NONE); + events.push(release(Key::X)); + let left = keys.frame_left(&mut app, 0.1, events); + assert!(app.hold_keys.pending.is_none(), "the dialog ends the wait"); + assert!( + !left.iter().any(|e| matches!(e, egui::Event::Text(_) | egui::Event::Key { pressed: true, .. })), + "neither the repeat nor its text reaches the dialog: {left:?}" + ); +} + /// A new wait does not drop a wait left in another viewport unseen: that wait ends, and its key's /// repeats stay held back in its viewport. #[test] From 2a5fc378b18ace8db0c4b0a2606e1a5fc528fbe1 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 18 Nov 2026 06:29:22 -0800 Subject: [PATCH 17/17] Preferences: number rows move out of category_fields category_fields reached clippy's cognitive complexity limit (31/30) once main took #8086. The Num arms move into num_row and num_field_row, next to bool_row and choice_row; the rows draw and save as before. --- crates/ui-egui/src/prefs_dialog.rs | 61 ++++++++++++++++-------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/crates/ui-egui/src/prefs_dialog.rs b/crates/ui-egui/src/prefs_dialog.rs index 8281690dd5..bc0a52604a 100644 --- a/crates/ui-egui/src/prefs_dialog.rs +++ b/crates/ui-egui/src/prefs_dialog.rs @@ -670,34 +670,7 @@ fn category_fields(ui: &mut egui::Ui, app: &mut VectorcraftApp, d: &mut Dialog, // says the change applies at the next start. PrefKind::Bool if sp.key == "lowLatencyDrawing" => desktop_startup_bool_row(ui, d, sp.key, sp.label, &t), PrefKind::Bool => bool_row(ui, d, sp.key, sp.label), - // General › Hold Shortcut Delay acts only while Hold Shortcuts is on: dimmed while it - // is off, as in Edit › Keyboard Shortcuts, which shows it only then. - PrefKind::Num { min, max, unit } if sp.key == "keyHoldDelay" => { - ui.add_enabled_ui(d.bool("holdShortcuts"), |ui| { - labeled(ui, sp.label, |ui, _| { - let x = v.as_f64().unwrap_or(min); - if let Some(x) = widgets::range_field(ui, sp.key, x, min..=max, &format!(" {unit}"), 3, 110.0) { - d.fields.insert(sp.key.into(), json!(x)); - } - }); - }); - } - PrefKind::Num { min, max, unit } => { - labeled(ui, sp.label, |ui, label_id| { - let mut x = v.as_f64().unwrap_or(min); - let new = if sp.key == "uiScaling" { - // Without internal text, both slider controls inherit the row's name across focus changes. - let response = widgets::slider(ui, egui::Slider::new(&mut x, min..=max).step_by(0.05)).labelled_by(label_id); - ui.add(egui::Label::new(tl!("Smaller ↔ Larger")).wrap_mode(egui::TextWrapMode::Extend)); - response.changed().then_some(x) - } else { - widgets::range_field(ui, sp.key, x, min..=max, &format!(" {unit}"), 3, 110.0) - }; - if let Some(x) = new { - d.fields.insert(sp.key.into(), json!(x)); - } - }); - } + PrefKind::Num { min, max, unit } => num_row(ui, d, sp.key, sp.label, min..=max, unit, &v), PrefKind::Length { min, max, measure } => { // In the dialog's own Units choice, so a change there shows right away. let unit = vectorcraft_doc::Unit::named(&d.str(measure.pref_key())).unwrap_or_default(); @@ -896,6 +869,38 @@ fn choice_row(ui: &mut egui::Ui, d: &mut Dialog, key: &str, label: &str, opts: & }); } +/// The row of the number preference `key` within `range`: a slider for Interface Scaling, a field +/// shown with `unit` otherwise. +fn num_row(ui: &mut egui::Ui, d: &mut Dialog, key: &str, label: &str, range: std::ops::RangeInclusive, unit: &str, v: &Value) { + if key == "uiScaling" { + labeled(ui, label, |ui, label_id| { + let mut x = v.as_f64().unwrap_or(*range.start()); + // Without internal text, both slider controls inherit the row's name across focus changes. + let response = widgets::slider(ui, egui::Slider::new(&mut x, range).step_by(0.05)).labelled_by(label_id); + ui.add(egui::Label::new(tl!("Smaller ↔ Larger")).wrap_mode(egui::TextWrapMode::Extend)); + if response.changed() { + d.fields.insert(key.into(), json!(x)); + } + }); + } else if key == "keyHoldDelay" { + // General › Hold Shortcut Delay acts only while Hold Shortcuts is on: dimmed while it + // is off, as in Edit › Keyboard Shortcuts, which shows it only then. + ui.add_enabled_ui(d.bool("holdShortcuts"), |ui| num_field_row(ui, d, key, label, range, unit, v)); + } else { + num_field_row(ui, d, key, label, range, unit, v); + } +} + +/// A number field for the preference `key`, kept within `range` and shown with `unit`. +fn num_field_row(ui: &mut egui::Ui, d: &mut Dialog, key: &str, label: &str, range: std::ops::RangeInclusive, unit: &str, v: &Value) { + labeled(ui, label, |ui, _| { + let x = v.as_f64().unwrap_or(*range.start()); + if let Some(x) = widgets::range_field(ui, key, x, range, &format!(" {unit}"), 3, 110.0) { + d.fields.insert(key.into(), json!(x)); + } + }); +} + fn bool_row(ui: &mut egui::Ui, d: &mut Dialog, key: &str, label: &str) { // The app's outlined checkbox (it translates `label`): egui's own has no border at rest. let on = d.bool(key);