mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -04:00
Avoid deadlocks by using lambdas for context lock (#2625)
ctx.input().key_pressed(Key::A) -> ctx.input(|i| i.key_pressed(Key::A))
This commit is contained in:
@@ -33,14 +33,14 @@ impl eframe::App for Content {
|
||||
ui.label(&self.text);
|
||||
});
|
||||
|
||||
if ctx.input().key_pressed(Key::A) {
|
||||
if ctx.input(|i| i.key_pressed(Key::A)) {
|
||||
self.text.push_str("\nPressed");
|
||||
}
|
||||
if ctx.input().key_down(Key::A) {
|
||||
if ctx.input(|i| i.key_down(Key::A)) {
|
||||
self.text.push_str("\nHeld");
|
||||
ui.ctx().request_repaint(); // make sure we note the holding.
|
||||
}
|
||||
if ctx.input().key_released(Key::A) {
|
||||
if ctx.input(|i| i.key_released(Key::A)) {
|
||||
self.text.push_str("\nReleased");
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user