diff --git a/crates/draw/src/ui/shape/stroke_cells.rs b/crates/draw/src/ui/shape/stroke_cells.rs index 4d89c97be..02e46a629 100644 --- a/crates/draw/src/ui/shape/stroke_cells.rs +++ b/crates/draw/src/ui/shape/stroke_cells.rs @@ -40,7 +40,7 @@ pub(super) fn style_button( ) { let off = appearance.stroke_width <= 0.0; let style = Bind::given(appearance.stroke_style.clone()); - let button = StrokeButton::new(words.stroke_style.clone(), style, open.reborrowed()).corners(corners).stroked(!off).enabled(!off); + let button = StrokeButton::new(words.stroke_style.clone(), style, open.reborrowed()).corners(corners).stroked(!off); for event in button.show(ui).events { let width = (off && matches!(event, EditEvent::Set { .. } | EditEvent::Begin { .. })).then_some(ShapeChange::ENABLED_STROKE_WIDTH); out.push(event.map(|style| ShapeChange::StrokeStyle { style, width })); diff --git a/crates/ui-contract/src/runtime/commands/board.rs b/crates/ui-contract/src/runtime/commands/board.rs index 0b89102d3..ed54cdd2b 100644 --- a/crates/ui-contract/src/runtime/commands/board.rs +++ b/crates/ui-contract/src/runtime/commands/board.rs @@ -467,8 +467,9 @@ pub fn keymap_builds() -> u64 { } /// The keymap of `registry` and the app catalog `app` on `platform` under `overrides`, and the chords it binds to the -/// edit commands and to the window's keys. A catalog command whose id the registry has stays out: the registry's -/// definition is the command's. +/// edit commands and to the window's keys. A catalog command whose id the registry has keeps the registry's +/// definition, and the catalog's default bindings join the registry's after them (an app's alternate keys, such as +/// F2/F3/F4 for Cut/Copy/Paste). /// /// A window shortcut's default chord that another command also binds is that command's: the window shortcut loses it, so the /// app's binding beats the framework's default. A window shortcut the overrides name keeps what they give it. @@ -486,6 +487,17 @@ fn build_keymap(registry: ®istry::Registry, app: Option<&AppCatalog>, platfor // The window-shortcut yield and the edit chords below read the registry's definitions only. let joined = |defs: &[CommandDef]| -> Vec { defs.iter().chain(&app_defs).cloned().collect() }; let mut defs = registry.defs_for(platform); + if let Some(app) = app { + for extra in app.defs() { + if let Some(def) = defs.iter_mut().find(|def| def.command == extra.command) { + for binding in &extra.defaults { + if !def.defaults.contains(binding) { + def.defaults.push(binding.clone()); + } + } + } + } + } let mut keymap = keymap_of(joined(defs.as_slice()), scopes.clone(), platform, overrides); let overridden = |def: &CommandDef| overrides.is_some_and(|overrides| overrides.get(&def.command.id).is_some()); let yielded: Vec<(CommandRef, Trigger)> = defs diff --git a/crates/ui-contract/src/runtime/pen.rs b/crates/ui-contract/src/runtime/pen.rs index fa5554f23..2605c052d 100644 --- a/crates/ui-contract/src/runtime/pen.rs +++ b/crates/ui-contract/src/runtime/pen.rs @@ -56,7 +56,7 @@ impl PenSource { } /// The latest reading, if the pen is on the tablet. - pub(crate) fn current(&self) -> Option { + pub fn current(&self) -> Option { self.lock().current } diff --git a/crates/ui-panels/src/dialog/host.rs b/crates/ui-panels/src/dialog/host.rs index 12782e391..b5df26fec 100644 --- a/crates/ui-panels/src/dialog/host.rs +++ b/crates/ui-panels/src/dialog/host.rs @@ -474,7 +474,12 @@ impl DialogHost { } } + /// Refuses (returns `false`) while a child is open over the dialog: the child's answer comes first, as the + /// disabled parent shows on screen. fn confirm_at(&mut self, ctx: &Context, at: usize) -> bool { + if self.stack.has_child(self.open[at].id()) { + return false; + } let Some(result) = self.open[at].confirm_erased(ctx) else { return false }; let id = self.open[at].id(); self.remove_tree(id); diff --git a/crates/ui-panels/tests/it/dialogs.rs b/crates/ui-panels/tests/it/dialogs.rs index d5f51e656..cab8da726 100644 --- a/crates/ui-panels/tests/it/dialogs.rs +++ b/crates/ui-panels/tests/it/dialogs.rs @@ -43,6 +43,10 @@ impl StackDialog for Probe { self.shows += 1; self.finish.take() } + + fn confirm(&mut self, _: &egui::Context) -> Option { + Some(N as u32) + } } fn run(host: &mut DialogHost, frames: &mut Frames) { @@ -75,6 +79,21 @@ fn cancelling_a_parent_cancels_its_children() { assert_eq!(host.take::>(), Some(DialogResult::Cancel)); } +/// OK on a dialog waits for the child open over it: the host refuses the parent's confirm until the child closes. +#[trial] +fn a_parent_with_an_open_child_refuses_confirm() { + let mut frames = Frames::new(); + let mut host = DialogHost::new(); + let parent = host.open(Probe::<1>::new("parent")); + let child = host.open_child(Probe::<2>::new("child"), parent); + run(&mut host, &mut frames); + assert!(!host.confirm_by_id(&frames.ctx, parent), "the parent's OK waits for its child"); + assert!(host.is_open::>() && host.is_open::>()); + assert!(host.confirm_by_id(&frames.ctx, child)); + assert!(host.confirm_by_id(&frames.ctx, parent), "with the child closed, the parent confirms"); + assert_eq!(host.take::>(), Some(DialogResult::Ok(1))); +} + /// A story of a hosted alert whose title is the story's `title` knob. fn titled_alert(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { let title = *data.value("title", "Could not open");