1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 23:00:04 -04:00

Create custom egui_kittest::Node (#7138)

This adds a custom Node struct with proper support for egui types
(`Key`, `Modifiers`, `egui::Event`, `Rect`) instead of needing to use
the kittest / accesskit types.

I also changed the `click` function to do a proper mouse move / mouse
down instead of the accesskit click. Also added `accesskit_click` to
trigger the accesskit event. This resulted in some changed snapshots,
since the elements are now hovered.

Also renamed `press_key` to `key_press` for consistency with
`key_down/key_up`.

Also removed the Deref to the AccessKit Node, to make it clearer when to
expect egui and when to expect accesskit types.

* Closes #5705 
* [x] I have followed the instructions in the PR template
This commit is contained in:
Lucas Meurer
2025-06-17 12:17:38 +02:00
committed by GitHub
parent 8c2df4802c
commit 0152a87519
20 changed files with 359 additions and 305 deletions

View File

@@ -10,19 +10,19 @@ pub fn focus_should_skip_over_disabled_buttons() {
ui.add(Button::new("Button 3"));
});
harness.press_key(egui::Key::Tab);
harness.key_press(egui::Key::Tab);
harness.run();
let button_1 = harness.get_by_label("Button 1");
assert!(button_1.is_focused());
harness.press_key(egui::Key::Tab);
harness.key_press(egui::Key::Tab);
harness.run();
let button_3 = harness.get_by_label("Button 3");
assert!(button_3.is_focused());
harness.press_key(egui::Key::Tab);
harness.key_press(egui::Key::Tab);
harness.run();
let button_1 = harness.get_by_label("Button 1");
@@ -41,13 +41,13 @@ pub fn focus_should_skip_over_disabled_drag_values() {
ui.add(egui::DragValue::new(&mut value_3));
});
harness.press_key(egui::Key::Tab);
harness.key_press(egui::Key::Tab);
harness.run();
let drag_value_1 = harness.get_by(|node| node.numeric_value() == Some(1.0));
assert!(drag_value_1.is_focused());
harness.press_key(egui::Key::Tab);
harness.key_press(egui::Key::Tab);
harness.run();
let drag_value_3 = harness.get_by(|node| node.numeric_value() == Some(3.0));
@@ -103,8 +103,7 @@ fn test_combobox() {
results.add(harness.try_snapshot("combobox_opened"));
let item_2 = harness.get_by_role_and_label(Role::Button, "Item 2");
// Node::click doesn't close the popup, so we use simulate_click
item_2.simulate_click();
item_2.click();
harness.run();