mirror of
https://github.com/storytold/craft-libs.git
synced 2026-12-01 10:48:15 +01:00
Merge pull request #4586 from davidmann4/fix/help-search-typing
Menus: typed letters land in the Help search (photocraft#18548)
This commit is contained in:
2 files changed
+21
-1
No files matched your search
@@ -584,7 +584,10 @@ pub(super) fn focused_claims(record: &focus::FocusedRecord, stage: &Stage) -> Ve
|
||||
fn state_claims(record: &focus::FocusedRecord, stage: &Stage) -> Vec<Chord> {
|
||||
let mut claims = Vec::new();
|
||||
let canvas = record.canvas.filter(|_| !record.foreign);
|
||||
let holds = |owner: Id| [record.focused, record.root, record.menu, record.menu_bar].contains(&Some(owner));
|
||||
// A text field in a menu (Help's search) keeps its typing: the letters the menu level claims for its rows'
|
||||
// mnemonics hold only while focus is on a row.
|
||||
let menu = record.menu.filter(|_| !record.keys.is_some_and(|keys| keys.owner == OwnerClass::Text));
|
||||
let holds = |owner: Id| [record.focused, record.root, menu, record.menu_bar].contains(&Some(owner));
|
||||
// The unfocused canvas's tool never takes Tab or Shift+Tab: with nothing focused they move focus into the window,
|
||||
// so a tool that claims the plain keys cannot trap keyboard navigation.
|
||||
let canvas_holds =
|
||||
|
||||
@@ -344,6 +344,23 @@ fn the_help_search_takes_its_editing_keys() {
|
||||
assert!(field_reads(&fixture, "txo"), "Left moves the caret before the last letter");
|
||||
}
|
||||
|
||||
/// A letter typed as a keyboard sends it, a key press with its text, lands in the focused Help search, also a letter a
|
||||
/// Help row or a bar title marks: the field keeps About's A and Help's H, and Help stays open.
|
||||
#[trial]
|
||||
fn a_typed_letter_a_help_row_marks_lands_in_the_help_search() {
|
||||
let (mut fixture, count, _) = scoped_rig();
|
||||
let help = fixture.by_label("Help").expect("the Help title");
|
||||
fixture.click(&help);
|
||||
fixture.settle();
|
||||
for (key, text) in [(egui::Key::A, "a"), (egui::Key::H, "h"), (egui::Key::B, "b")] {
|
||||
fixture.type_key(key, text);
|
||||
fixture.settle();
|
||||
}
|
||||
assert!(fixture.by_label("About").is_some(), "Help stays open");
|
||||
assert!(fixture.texts().iter().any(|run| run.text == "ahb"), "every letter lands in the search field");
|
||||
assert_eq!(count.get(), 0, "and run nothing");
|
||||
}
|
||||
|
||||
/// A command chord pressed after the focus moved between the rows of an open menu still runs in the scope focus came
|
||||
/// from and gives the focus back there, for a menu a title click opened and one F10 and Down opened.
|
||||
#[trial]
|
||||
|
||||
Reference in new issue
Block a user