Merge pull request #10642 from dotCooCoo/fix/menu-model-no-rebuild-per-press

Menus: a click on the canvas or a key the canvas takes keeps the menu states
This commit is contained in:
.CooCoo authored and GitHub committed 2026-12-03 07:33:08 -08:00
commit 094523b017
8 files changed
+266 -49

No files matched your search

+2
View File
@@ -168,6 +168,8 @@ impl VectorcraftApp {
carry_target: None,
last_drag: None,
escaped_press: false,
pressed_at: None,
keys_at: None,
host_caps_lock: None,
committed_preview: false,
panes: Default::default(),
+6
View File
@@ -129,6 +129,12 @@ pub struct CanvasCache {
/// Escape cancelled the tool's press while the button is still down: its release still sends the tool its Up,
/// which gives back a selection tool Cmd lent.
pub escaped_press: bool,
/// The input time of the last pass whose pointer button events all landed on a canvas, with no other layer over it:
/// the menus' state key leaves such a press out (`menus::model::last_press`).
pub pressed_at: Option<f64>,
/// The input time of the last pass in which the canvas or nothing had the focus, so that the canvas or the app's
/// shortcuts took its keys: the menus' state key leaves those keys out (`menus::model::last_press`).
pub keys_at: Option<f64>,
/// The host's Caps Lock state at the last canvas pass, which `VectorcraftApp::follow_caps_lock` compares with the
/// next reading; `None` before the first pass.
pub host_caps_lock: Option<bool>,
+74 -17
View File
@@ -897,13 +897,12 @@ fn the_move_of_a_releasing_frame_counts_for_the_tool_drag() {
assert_eq!(draw(true), Rect::new(130.0, 115.0, 160.0, 130.0), "with Space held through the release the last move moves it");
}
/// A Selection tool move builds the menus' states again twice, in the frame of its press and in the frame of its
/// release, which commits the move. The frame the move begins in and the frames of its previews, which change the
/// document's revision, keep them. The menus are also built again when a process-wide catalog changes, so the fonts
/// and plug-ins are held steady against tests running alongside for the whole run, and the move runs again on a new
/// app, at most 20 times, until the other catalogs held still through it.
#[test]
fn a_selection_move_rebuilds_the_menus_for_its_press_and_release_only() {
/// How many times each frame of `steps` builds the menus' states again, with the Selection tool and a 60 × 30
/// rectangle at (100, 100) selected and the pointer resting over its middle (`steps` gets that point). The menus are
/// also built again when a process-wide catalog changes, so the fonts and plug-ins are held steady against tests
/// running alongside for the whole run, and the steps run again on a new app, at most 20 times, until the other
/// catalogs held still through them.
fn selection_tool_rebuilds(steps: impl Fn(Pos2, &craft::behavior::CanvasView) -> Vec<Vec<egui::Event>>) -> (VectorcraftApp, Vec<u64>) {
let fonts = vectorcraft_text::FontDb::global();
let _steady = (vectorcraft_text::test_fonts::steady_fonts(fonts), vectorcraft_plugins::steady::steady_plugins());
let catalogs = || {
@@ -920,33 +919,59 @@ fn a_selection_move_rebuilds_the_menus_for_its_press_and_release_only() {
let id = app.session.execute("shape.rectangle", &json!({"x": 100, "y": 100, "width": 60, "height": 30})).unwrap()["id"].as_u64().unwrap();
app.select_tool("selection");
app.session.execute("select.set", &json!({"ids": [id]})).unwrap();
let (from, to) = (xf.to_screen(Point::new(130.0, 115.0)), xf.to_screen(Point::new(170.0, 135.0)));
let from = xf.to_screen(Point::new(130.0, 115.0));
app_step(&mut app, &ctx, vec![egui::Event::PointerMoved(from)]);
for _ in 0..2 {
app_step(&mut app, &ctx, vec![]);
}
let none = egui::Modifiers::NONE;
let mut steps = vec![vec![primary(from, true, none)]];
steps.extend((1..=8).map(|i| vec![egui::Event::PointerMoved(from.lerp(to, i as f32 / 8.0))]));
steps.push(vec![primary(to, false, none)]);
steps.extend([vec![], vec![], vec![]]);
let mut rebuilt = vec![];
for events in steps {
for events in steps(from, &xf) {
let before = app.menus.rebuilds;
app_step(&mut app, &ctx, events);
rebuilt.push(app.menus.rebuilds - before);
}
(app, rebuilt)
};
let (app, rebuilt) = (0..20)
(0..20)
.find_map(|_| {
let before = catalogs();
let out = run();
(catalogs() == before).then_some(out)
})
.unwrap_or_else(|| panic!("tests running alongside kept changing the font and plug-in catalogs"));
.unwrap_or_else(|| panic!("tests running alongside kept changing the font and plug-in catalogs"))
}
/// A Selection tool move builds the menus' states again once, for the release that commits it. Its press lands on the
/// canvas, and the frame the move begins in and the frames of its previews, which change the document's revision, keep
/// them.
#[test]
fn a_selection_move_rebuilds_the_menus_for_its_release_only() {
let none = egui::Modifiers::NONE;
let (app, rebuilt) = selection_tool_rebuilds(|from, xf| {
let to = xf.to_screen(Point::new(170.0, 135.0));
let mut steps = vec![vec![primary(from, true, none)]];
steps.extend((1..=8).map(|i| vec![egui::Event::PointerMoved(from.lerp(to, i as f32 / 8.0))]));
steps.push(vec![primary(to, false, none)]);
steps.extend([vec![], vec![], vec![]]);
steps
});
assert_eq!(drawn_paths(&app), vec![Rect::new(140.0, 120.0, 200.0, 150.0)], "the drag moves the rectangle");
assert_eq!(rebuilt, [1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0], "rebuilds in each frame: press, 8 moves, release, 3 idle");
assert_eq!(rebuilt[..9].iter().sum::<u64>(), 0, "the press and the 8 moves keep the menus: {rebuilt:?}");
assert_eq!(rebuilt.iter().sum::<u64>(), 1, "the release that commits the move rebuilds them once: {rebuilt:?}");
}
/// A click on the selected rectangle that leaves it where it was, and F20 pressed and released with no field or dialog
/// taking it and no command on it, change nothing the menus show: no frame builds the menus' states again.
#[test]
fn a_canvas_click_that_changes_nothing_keeps_the_menus() {
let none = egui::Modifiers::NONE;
let f20 = |pressed| egui::Event::Key { key: egui::Key::F20, physical_key: None, pressed, repeat: false, modifiers: none };
let (app, rebuilt) = selection_tool_rebuilds(|from, _| {
vec![vec![primary(from, true, none)], vec![primary(from, false, none)], vec![f20(true)], vec![f20(false)], vec![], vec![]]
});
assert_eq!(drawn_paths(&app), vec![Rect::new(100.0, 100.0, 160.0, 130.0)], "the click leaves the rectangle where it was");
assert_eq!(app.session.active().map(|d| d.selection.objects.len()), Some(1), "the rectangle stays selected");
assert_eq!(rebuilt, [0; 6], "rebuilds in each frame: press, release, a key press and release, 2 idle");
}
/// #6369: only the selection box remains over the temporary halftone, and the original
@@ -4489,6 +4514,38 @@ fn plain(app: &VectorcraftApp, id: u64) -> String {
}
}
/// While the Type tool edits text, a click in the text and an arrow key, which move the caret without an edit, build
/// the menus' states again: the type rows read the caret's range.
#[test]
fn a_click_or_a_key_in_edited_text_rebuilds_the_menus() {
use egui::Event;
let mut app = VectorcraftApp::new(Session::new(), Default::default());
app.session.prefs.placeholder_text = false;
let ctx = crate::testing::ui_context();
let id = start_typing(&mut app, &ctx);
typing_frame(&mut app, &ctx, vec![Event::Text("abc".into())]);
typing_frame(&mut app, &ctx, vec![]);
let at = app.canvas_view().unwrap().to_screen(Point::new(101.0, 100.0));
let button = |pressed| Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE };
let left = |pressed| Event::Key { key: egui::Key::ArrowLeft, physical_key: None, pressed, repeat: false, modifiers: egui::Modifiers::NONE };
let rebuilds = |app: &mut VectorcraftApp, steps: Vec<Vec<Event>>| {
let before = app.menus.rebuilds;
for events in steps {
typing_frame(app, &ctx, events);
}
app.menus.rebuilds - before
};
let click = || vec![vec![Event::PointerMoved(at), button(true)], vec![button(false)]];
// The first click puts the caret there; the second leaves the document's revision as it is.
rebuilds(&mut app, click());
let revision = app.session.active().map(|d| d.revision);
assert!(rebuilds(&mut app, click()) > 0, "a click in the text");
assert_eq!(app.session.active().map(|d| d.revision), revision, "the click changes no revision");
assert!(rebuilds(&mut app, vec![vec![left(true)], vec![left(false)]]) > 0, "an arrow key in the text");
assert_eq!(plain(&app, id), "abc", "neither edits the text");
assert!(app.session.tool_wants_text(), "editing goes on");
}
/// Starts editing new point type with the Type tool; returns its id.
fn start_typing(app: &mut VectorcraftApp, ctx: &egui::Context) -> u64 {
app.session.execute("file.new", &json!({"width": 400, "height": 300})).unwrap();
+11
View File
@@ -656,6 +656,17 @@ pub(crate) fn run(app: &mut VectorcraftApp, ui: &mut Ui, pass: &ToolPass) -> Too
if ui.ctx().current_pass_index() == 0 && view_press {
app.session.tool_press_elsewhere();
}
// A press on the canvas, and a key while the canvas or nothing has the focus, change what the menus show only through
// the document, the tool or a command, which the menus' state key reads, so the key leaves them out
// (`menus::model::last_press`).
let presses: Vec<egui::Pos2> =
ui.input(|i| i.events.iter().filter_map(|e| if let egui::Event::PointerButton { pos, .. } = e { Some(*pos) } else { None }).collect());
if !presses.is_empty() && presses.iter().all(|&at| over(Some(at)) && ui.ctx().layer_id_at(at) == Some(ui.layer_id())) {
app.canvas.pressed_at = Some(ui.input(|i| i.time));
}
if ui.ctx().memory(|m| m.focused()).is_none_or(|id| id == pass.id) {
app.canvas.keys_at = Some(ui.input(|i| i.time));
}
let view_info = app.view_info();
let mut picked = ToolHostResponse::default();
let mut response = if crate::dialogs::recolor::edit_tab::with_theme_pick(app, |app, tool| picked = host_run(app, ui, pass, tool)) {
+34 -11
View File
@@ -92,9 +92,11 @@ pub(crate) fn translate_label(english: &'static str) -> String {
/// What the menus' rows depend on, cheaply (no allocation): commands run, the active document,
/// its revision (edits, selection and view changes), history and clipboard, the filter plug-in that ran last, the language,
/// shortcuts, plug-ins, the Scripts folder's listing, an open file dialog and the fonts (Type › Font lists the loaded fonts
/// until the installed ones are scanned, then all of them, #5483). `input`, the pass of the last frame with a pointer
/// button pressed or released or a key pressed ([`last_press`]), changes once for each, which covers what the hash
/// doesn't list (panels shown, a tool picked). While an
/// until the installed ones are scanned, then all of them, #5483), the tool, whether the panels show, the open panel
/// flyout, the dock workspace's identity and revision, the current window and whether a dialog is open or a shortcut
/// is being recorded. `input`, the pass of the last frame with a click away from the canvas or a key a field or a dialog
/// took ([`last_press`]), changes once for each, which covers what the hash
/// doesn't list (a panel's own state, a dialog's fields). While an
/// interaction is open (for example a move, scale or shape drag, a dialog's or the font menu's
/// preview, or a typing session), the hash takes the revision the interaction began from in place of the current one,
/// which each of its previews changes, and changes as it ends. The hash stays the same as a tool's drag begins. An
@@ -126,6 +128,14 @@ fn rows_key(app: &VectorcraftApp, input: Option<u64>) -> u64 {
// Apply Last Filter and Last Filter… are named after the filter that ran last.
app.last_filters.last_id().hash(&mut h);
app.file_dialog_open().hash(&mut h);
// What a click on the canvas or a key no field takes changes without a command: the tool (a tool's key, a held
// Space), the panels shown (Tab), the open panel flyout and the dock workspace's identity and revision (panels
// shown, hidden or moved), the current window, the view's rotation (Rotate View's checks) and active artboard
// (a selection tool's press on one), and a dialog opened or closed (Escape, Enter).
(s.tool_id(), crate::panel_docking::panels_shown(app), crate::doc_windows::current(app)).hash(&mut h);
(&app.ui.open_panel, std::sync::Arc::as_ptr(&app.ui.dock_workspace).addr(), app.ui.dock_workspace.revision()).hash(&mut h);
app.view().map(|v| (v.rotation.to_bits(), v.artboard)).hash(&mut h);
(app.any_dialog_open(), recording_shortcut(app)).hash(&mut h);
(crate::i18n::current().code(), plugin_revision(), crate::scripts_menu::revision(), crate::dialogs::proof_setup::saved_revision()).hash(&mut h);
hash_listed_names(&app.ui, &mut h);
let fonts = vectorcraft_text::FontDb::global();
@@ -216,20 +226,33 @@ fn lay_out(app: &mut VectorcraftApp, target: Target) {
}
}
/// The pass number of the last frame with a pointer button pressed or released or a key pressed, the frame `ctx` read
/// last included: the `input` of [`state_key`]. It stays the same over the frames after that one, so each of them
/// changes the key once.
/// The pass number of the last frame with a press that [`pressed_pass`] counts, the frame `ctx` read last included: the
/// `input` of [`state_key`]. It stays the same over the frames after that one, so each of them changes the key once.
pub(crate) fn last_press(app: &mut VectorcraftApp, ctx: &egui::Context) -> Option<u64> {
if let Some(pass) = pressed_pass(ctx) {
if let Some(pass) = pressed_pass(app, ctx) {
app.menus.pressed = Some(pass);
}
app.menus.pressed
}
/// The frame's pass number when it has a pointer button pressed or released (a click ends at the release) or a key
/// pressed.
fn pressed_pass(ctx: &egui::Context) -> Option<u64> {
let pressed = ctx.input(|i| i.events.iter().any(|e| matches!(e, egui::Event::PointerButton { .. } | egui::Event::Key { pressed: true, .. })));
/// The frame's pass number when it has a pointer button pressed or released (a click ends at the release) away from
/// the canvas, or a key pressed while a text field, a dialog or a panel's control has the keys. A click on the canvas
/// changes the rows only through the document, the tool or a command, and a key the canvas or the app's shortcuts take
/// only through those, the panels shown (Tab) or a dialog it opens or closes, which [`rows_key`] reads. While the tool
/// edits text, a click or a key on the canvas counts too: it moves the caret or the selected range, which the type rows
/// read.
fn pressed_pass(app: &VectorcraftApp, ctx: &egui::Context) -> Option<u64> {
let editing = app.session.tool_wants_text();
let typing = editing || WindowHost::of(ctx).typing() || app.any_dialog_open();
let pressed = ctx.input(|i| {
let on_canvas = !editing && app.canvas.pressed_at == Some(i.time);
let canvas_keys = !typing && app.canvas.keys_at == Some(i.time);
i.events.iter().any(|e| match e {
egui::Event::PointerButton { .. } => !on_canvas,
egui::Event::Key { pressed: true, .. } => !canvas_keys,
_ => false,
})
});
pressed.then(|| ctx.cumulative_pass_nr())
}
+3 -2
View File
@@ -39,8 +39,9 @@ pub(crate) fn run(app: &mut VectorcraftApp, ctx: &egui::Context) {
}
}
/// Once per frame, after the UI: bring the native menu up to date. A frame with a click or a key
/// press reads the menus again, as input may change state the key doesn't list.
/// Once per frame, after the UI: bring the native menu up to date. A frame with a click away from
/// the canvas or a key a field or a dialog took reads the menus again, as that input may change
/// state the key doesn't list ([`last_press`]).
pub(crate) fn sync(app: &mut VectorcraftApp, ctx: &egui::Context) {
if app.services.native_menu.is_none() {
return;
+122 -19
View File
@@ -209,13 +209,10 @@ fn window_menu_labels_start_in_one_column() {
}
/// An app with a new document whose installed fonts are cataloged, after the frames that build its first menus and the
/// window's keymap. It runs in a process of its own ([`crate::testing::in_own_process`]): the menus' key holds the
/// installed plug-ins' revision and the fonts' generation, which are the whole process's, so a plug-in that another test
/// installs, or a font it adds, rebuilds this app's menus. `None` in the parent process.
fn settled_app(test: &str) -> Option<(VectorcraftApp, egui::Context)> {
if !crate::testing::in_own_process(test) {
return None;
}
/// window's keymap. Each test that uses it runs in a process of its own ([`crate::testing::in_own_process`]): the menus'
/// key holds the installed plug-ins' revision and the fonts' generation, which are the whole process's, so a plug-in
/// that another test installs, or a font it adds, rebuilds this app's menus.
fn settled_app() -> (VectorcraftApp, egui::Context) {
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default());
// The scan of the installed fonts, which the app starts, changes the fonts' generation when it ends: wait for it.
vectorcraft_text::FontDb::global().family_list();
@@ -224,25 +221,128 @@ fn settled_app(test: &str) -> Option<(VectorcraftApp, egui::Context)> {
for _ in 0..3 {
app_frame(&mut app, &ctx, vec![]);
}
Some((app, ctx))
(app, ctx)
}
/// A key press builds the menus' states again once: the frames after it, with no press, keep them.
/// A key press that a dialog takes builds the menus' states again once: the frames after it, with no press, keep them.
/// The same key with no dialog or field to take it keeps them.
#[test]
fn a_key_press_rebuilds_the_menus_once() {
let Some((mut app, ctx)) = settled_app("menus::tests::a_key_press_rebuilds_the_menus_once") else { return };
let before = app.menus.rebuilds;
fn a_key_press_a_dialog_takes_rebuilds_the_menus_once() {
if !crate::testing::in_own_process("menus::tests::a_key_press_a_dialog_takes_rebuilds_the_menus_once") {
return;
}
let (mut app, ctx) = settled_app();
// F20 runs no command and changes nothing the menus show.
let press = |pressed| egui::Event::Key { key: egui::Key::F20, physical_key: None, pressed, repeat: false, modifiers: egui::Modifiers::NONE };
let rebuilds = |app: &mut VectorcraftApp, events: Vec<egui::Event>| {
let before = app.menus.rebuilds;
app_frame(app, &ctx, events);
for _ in 0..4 {
app_frame(app, &ctx, vec![]);
}
app.menus.rebuilds - before
};
assert_eq!(rebuilds(&mut app, vec![]), 0, "idle frames keep the menus");
assert_eq!(rebuilds(&mut app, vec![press(true), press(false)]), 0, "a key nothing takes keeps the menus");
app.run("file.documentSetup", json!({})).unwrap();
rebuilds(&mut app, vec![]);
// No field of the dialog has the keys: the dialog itself takes them.
ctx.memory_mut(|m| {
if let Some(field) = m.focused() {
m.surrender_focus(field);
}
});
rebuilds(&mut app, vec![]);
assert!(app.any_dialog_open(), "Document Setup is open");
assert!(!craft::ui::runtime::windows::WindowHost::of(&ctx).typing(), "no text field has the keys");
assert_eq!(rebuilds(&mut app, vec![press(true), press(false)]), 1, "a key the dialog takes rebuilds the menus once");
}
/// Show or Hide Panels, which the framework runs itself (Tab) with no app command, takes the check marks off the Window
/// menu's panel rows.
#[test]
fn hiding_the_panels_unchecks_the_window_rows() {
use craft::ui::runtime::commands::{ChromeCommand, CommandSet as _, CommandState, FireSource};
if !crate::testing::in_own_process("menus::tests::hiding_the_panels_unchecks_the_window_rows") {
return;
}
let (mut app, ctx) = settled_app();
let checked_panels = |app: &VectorcraftApp| {
app.menus
.bar
.items()
.into_iter()
.filter(|it| it.command.id == "window.panel" && app.menus.states.get(&it.command).and_then(CommandState::is_checked) == Some(true))
.count()
};
assert!(checked_panels(&app) > 0, "a panel shows, and its Window row is checked");
let raw = || egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1600.0, 850.0))), ..Default::default() };
crate::testing::part_frame(&mut app, &ctx, raw(), |app, ui| {
craft::ui::runtime::commands::fire(ui.ctx(), CommandRef::new(ChromeCommand::TogglePanels.id()), FireSource::Menu);
app.tick(ui.ctx());
app.ui(ui);
});
for _ in 0..3 {
app_frame(&mut app, &ctx, vec![]);
}
assert_eq!(app.menus.rebuilds, before, "idle frames keep the menus");
// F20 runs no command and changes nothing the menus show.
let press = |pressed| egui::Event::Key { key: egui::Key::F20, physical_key: None, pressed, repeat: false, modifiers: egui::Modifiers::NONE };
app_frame(&mut app, &ctx, vec![press(true), press(false)]);
for _ in 0..4 {
assert!(!crate::panel_docking::panels_shown(&app), "the panels are hidden");
assert_eq!(checked_panels(&app), 0, "no Window row is checked while the panels are hidden");
}
/// A panel flyout opened or closed without a command or input updates its Window row's check mark.
#[test]
fn closing_a_panel_flyout_unchecks_its_window_row() {
use craft::ui::runtime::commands::CommandState;
if !crate::testing::in_own_process("menus::tests::closing_a_panel_flyout_unchecks_its_window_row") {
return;
}
let (mut app, ctx) = settled_app();
let row = app
.menus
.bar
.items()
.into_iter()
.find(|it| {
it.command.id == "window.panel"
&& it.command.params["panel"]
.as_str()
.is_some_and(|panel| crate::panel_docking::layout_of(&app.ui).opens_in_flyout(&panel.to_owned()))
})
.expect("the default layout has an iconic panel's Window row")
.command
.clone();
let checked = |app: &VectorcraftApp| app.menus.states.get(&row).and_then(CommandState::is_checked) == Some(true);
app.ui.open_panel = Some(row.params["panel"].as_str().unwrap().to_owned());
for _ in 0..2 {
app_frame(&mut app, &ctx, vec![]);
}
assert_eq!(app.menus.rebuilds, before + 1);
assert!(checked(&app), "the Window row is checked while its panel shows in a flyout");
app.ui.open_panel = None;
for _ in 0..2 {
app_frame(&mut app, &ctx, vec![]);
}
assert!(!checked(&app), "the Window row is unchecked after its panel's flyout closes");
}
/// A view turned by the canvas's navigation (a Shift+drag on the canvas), with no command and no document change, moves
/// View › Rotate View's check to the angle it was turned to.
#[test]
fn a_view_turned_on_the_canvas_moves_the_rotate_view_check() {
use craft::ui::runtime::commands::CommandState;
if !crate::testing::in_own_process("menus::tests::a_view_turned_on_the_canvas_moves_the_rotate_view_check") {
return;
}
let (mut app, ctx) = settled_app();
let rows: Vec<CommandRef> = app.menus.bar.items().into_iter().filter(|it| it.command.id == "view.rotate").map(|it| it.command.clone()).collect();
let angle = |row: &CommandRef| row.params["angle"].as_f64().unwrap_or(0.0);
let turned = rows.iter().find(|row| angle(row) != 0.0).expect("Rotate View lists an angle other than 0").clone();
let checked = |app: &VectorcraftApp, row: &CommandRef| app.menus.states.get(row).and_then(CommandState::is_checked) == Some(true);
assert!(!checked(&app, &turned), "the view starts unturned");
app.view_mut().expect("a view").rotation = angle(&turned);
for _ in 0..2 {
app_frame(&mut app, &ctx, vec![]);
}
assert!(checked(&app, &turned), "the angle the view is turned to is checked");
}
/// A font added to the fonts the whole process shares builds the menus again with no input, Type › Font then lists it,
@@ -250,7 +350,10 @@ fn a_key_press_rebuilds_the_menus_once() {
#[test]
fn a_new_font_rebuilds_the_menus() {
const FAMILY: &str = "Menurebuild Sans";
let Some((mut app, ctx)) = settled_app("menus::tests::a_new_font_rebuilds_the_menus") else { return };
if !crate::testing::in_own_process("menus::tests::a_new_font_rebuilds_the_menus") {
return;
}
let (mut app, ctx) = settled_app();
let lists =
|app: &VectorcraftApp| app.menus.bar.items().into_iter().any(|it| it.command.id == "text.setStyle" && it.command.params["font"] == FAMILY);
assert!(!lists(&app));
+14
View File
@@ -1257,6 +1257,20 @@ fn the_overflow_menu_of_a_docked_group_is_reached_and_used_from_the_keyboard() {
assert!(h.strip_has_focus(), "the focus stays on the strip after the pick");
}
/// A key that a panel's control takes builds the menus' states again: the control can change what a panel menu row
/// reads without running a command.
#[test]
fn a_key_a_panel_control_takes_rebuilds_the_menus() {
let mut h = Harness::new();
let strip = h.named("Panels", egui::accesskit::Role::TabList).expect("a group's tab strip");
h.click(pos2(strip.center().x, strip.bottom() + 25.0));
assert!(h.strip_has_focus(), "a press in the group focuses its strip");
let before = h.app.menus.rebuilds;
h.press(egui::Key::F20, egui::Modifiers::NONE);
h.frames(2);
assert!(h.app.menus.rebuilds > before, "the key the strip took rebuilds the menus");
}
/// A tab group dragged out of the icon column by its grip floats as an expanded panel: its tabs show
/// in the window, and a click on each tab shows that panel.
#[test]