1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 22:00:03 -04:00

Fix disabled widgets "eating" focus (#5370)

- fixes https://github.com/emilk/egui/issues/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.
This commit is contained in:
lucasmerlin
2024-11-26 14:31:30 +01:00
committed by GitHub
parent 83a30064f4
commit 9ecc0b232c
5 changed files with 58 additions and 2 deletions

View File

@@ -249,6 +249,25 @@ impl<'a, State> Harness<'a, State> {
pub fn state_mut(&mut self) -> &mut State {
&mut self.state
}
/// Press a key.
/// This will create a key down event and a key up event.
pub fn press_key(&mut self, key: egui::Key) {
self.input.events.push(egui::Event::Key {
key,
pressed: true,
modifiers: Default::default(),
repeat: false,
physical_key: None,
});
self.input.events.push(egui::Event::Key {
key,
pressed: false,
modifiers: Default::default(),
repeat: false,
physical_key: None,
});
}
}
/// Utilities for stateless harnesses.