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

Fix Response::interact and Ui:interact_with_hovered (#4013)

These broke in 0.26

* #3989
* #4006
This commit is contained in:
Emil Ernerfeldt
2024-02-10 10:48:00 +01:00
parent db00dc6ea5
commit df7e4a5db6
4 changed files with 55 additions and 5 deletions

View File

@@ -357,6 +357,8 @@ pub struct InputTest {
#[cfg_attr(feature = "serde", serde(skip))]
history: [DeduplicatedHistory; 4],
late_interaction: bool,
show_hovers: bool,
}
@@ -394,6 +396,8 @@ impl super::View for InputTest {
ui.checkbox(&mut self.show_hovers, "Show hover state");
});
ui.checkbox(&mut self.late_interaction, "Use Response::interact");
ui.label("This tests how egui::Response reports events.\n\
The different buttons are sensitive to different things.\n\
Try interacting with them with any mouse button by clicking, double-clicking, triple-clicking, or dragging them.");
@@ -409,7 +413,13 @@ impl super::View for InputTest {
.enumerate()
{
columns[i].push_id(i, |ui| {
let response = ui.add(egui::Button::new(sense_name).sense(sense));
let response = if self.late_interaction {
let first_response =
ui.add(egui::Button::new(sense_name).sense(egui::Sense::hover()));
first_response.interact(sense)
} else {
ui.add(egui::Button::new(sense_name).sense(sense))
};
let info = response_summary(&response, self.show_hovers);
self.history[i].add(info.trim().to_owned());
self.history[i].ui(ui);