-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix disabled widgets "eating" focus (#5370)
- fixes #5359 For the test I added a `Harness::press_key` function. We should eventually add these to kittest, probably via a trait one can implement for the `Harness` but for now this should do.
- Loading branch information
1 parent
83a3006
commit 9ecc0b2
Showing
5 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use egui::Button; | ||
use egui_kittest::kittest::Queryable; | ||
use egui_kittest::Harness; | ||
|
||
#[test] | ||
pub fn focus_should_skip_over_disabled_buttons() { | ||
let mut harness = Harness::new_ui(|ui| { | ||
ui.add(Button::new("Button 1")); | ||
ui.add_enabled(false, Button::new("Button Disabled")); | ||
ui.add(Button::new("Button 3")); | ||
}); | ||
|
||
harness.press_key(egui::Key::Tab); | ||
harness.run(); | ||
|
||
let button_1 = harness.get_by_name("Button 1"); | ||
assert!(button_1.is_focused()); | ||
|
||
harness.press_key(egui::Key::Tab); | ||
harness.run(); | ||
|
||
let button_3 = harness.get_by_name("Button 3"); | ||
assert!(button_3.is_focused()); | ||
|
||
harness.press_key(egui::Key::Tab); | ||
harness.run(); | ||
|
||
let button_1 = harness.get_by_name("Button 1"); | ||
assert!(button_1.is_focused()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters