diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index bd7e18795..2bab12ba0 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -6,7 +6,7 @@ use super::state::{FilePlace, FilePurpose, LocatedPlace, RECENT_MAX, ViewMode}; #[cfg(not(target_arch = "wasm32"))] use super::updates_ui; use super::{ - AnimPreview, FileTarget, HashMap, InputTarget, Mods, PendingFile, Perf, Platform, Session, SlideApp, Target, UiRequest, Value, backstage, + AnimPreview, FileTarget, HashMap, InputTarget, PendingFile, Perf, Platform, Session, SlideApp, Target, UiRequest, Value, backstage, dialogs, doc_window, json, media, menus, preview, qat, ribbon, show, sorter, status, toast, }; use craft::ui::contract::{Bind, CommandSet as _, Tracked}; diff --git a/crates/ui-egui/src/app/keys.rs b/crates/ui-egui/src/app/keys.rs index 76151887b..6b3b95602 100644 --- a/crates/ui-egui/src/app/keys.rs +++ b/crates/ui-egui/src/app/keys.rs @@ -1,4 +1,4 @@ -use super::{Mods, SlideApp}; +use super::SlideApp; use craft::keymap::{Chord, Key, Mods as KeyMods}; use craft::ui::runtime::focus; use craft::ui::runtime::keys::{Intent, with_window_intents}; @@ -41,21 +41,13 @@ impl SlideApp { break; } match event { - egui::Event::Key { key, pressed: true, modifiers, .. } => { - let mods = - Mods { shift: modifiers.shift, alt: modifiers.alt, cmd: modifiers.command || (!self.session.mac_keys && modifiers.ctrl) }; - if key == egui::Key::Tab && !focus::has_any(ctx) { - // The slide has the keyboard, so Tab is ours (indent, tab character, next - // shape). Left to egui it would also focus the first ribbon widget, and - // every key after it would go there instead of the slide (#78). - ctx.memory_mut(|m| m.move_focus(egui::FocusDirection::None)); - } - if focus::has_any(ctx) { - continue; - } - if let Err(error) = self.session.key(key_name(key), mods) { - self.set_status(error.to_string()); - } + // Bound chords fire through the command catalogue and the canvas tool's key claims + // run the slide's own keys, so a key event here only keeps Tab on the slide. + egui::Event::Key { key: egui::Key::Tab, pressed: true, .. } if !focus::has_any(ctx) => { + // The slide has the keyboard, so Tab is ours (indent, tab character, next + // shape). Left to egui it would also focus the first ribbon widget, and + // every key after it would go there instead of the slide (#78). + ctx.memory_mut(|m| m.move_focus(egui::FocusDirection::None)); } // egui 0.37 carries a clipboard image as its own event; it inserts once. egui::Event::PasteImage(image) if !focus::has_any(ctx) => { diff --git a/crates/ui-egui/src/tests.rs b/crates/ui-egui/src/tests.rs index 30d327c6f..161a056b6 100644 --- a/crates/ui-egui/src/tests.rs +++ b/crates/ui-egui/src/tests.rs @@ -830,15 +830,18 @@ fn missing_recent_is_marked_and_its_error_shows() { /// The existence probe tells present files from missing ones and never touches remote paths. #[test] fn recent_exists_tells_missing_from_present() { - let mut harness = crate::test_harness::harness(Session::new(), Services::default()); + let path = std::path::PathBuf::from("/deckcraft-tests/172/present.deckcraft"); + let files = std::sync::Arc::new(craft::host::ScriptedFiles::new().with_file(&path, Vec::new())); + let mut harness = crate::test_harness::harness_with( + Session::new(), + Services::default(), + egui_kittest::Harness::builder().with_size(egui::vec2(1440.0, 900.0)), + |platform| platform.host = platform.host.with_files(files), + ); let app = harness.state_mut(); - let mut path = std::env::temp_dir(); - path.push(format!("deckcraft-test-172-{}.deckcraft", std::process::id())); - std::fs::write(&path, b"").unwrap(); assert!(app.recent_exists(&path.to_string_lossy()), "the file exists"); assert!(!app.recent_exists("/deckcraft-tests/172/missing.deckcraft")); assert!(app.recent_exists("\\\\server/share/deck.deckcraft"), "UNC paths are never probed"); - std::fs::remove_file(&path).ok(); } /// #339: clicking a language in Review > Language did nothing, and OK didn't mark the text.