mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 05:10:03 -04:00
On touch screens, press-and-hold equals a secondary click (#4195)
* Closes https://github.com/emilk/egui/issues/3444 * Closes https://github.com/emilk/egui/issues/865 On a touch screen, if you press down on a widget and hold for 0.6 seconds (`MAX_CLICK_DURATION`), it will now trigger a secondary click, i.e. `Response::secondary_clicked` will be `true`. This means you can now open context menus on touch screens.
This commit is contained in:
@@ -80,6 +80,8 @@ impl super::View for ContextMenus {
|
||||
ui.label("Right-click plot to edit it!");
|
||||
ui.horizontal(|ui| {
|
||||
self.example_plot(ui).context_menu(|ui| {
|
||||
ui.set_min_width(220.0);
|
||||
|
||||
ui.menu_button("Plot", |ui| {
|
||||
if ui.radio_value(&mut self.plot, Plot::Sin, "Sin").clicked()
|
||||
|| ui
|
||||
@@ -96,12 +98,12 @@ impl super::View for ContextMenus {
|
||||
ui.add(
|
||||
egui::DragValue::new(&mut self.width)
|
||||
.speed(1.0)
|
||||
.prefix("Width:"),
|
||||
.prefix("Width: "),
|
||||
);
|
||||
ui.add(
|
||||
egui::DragValue::new(&mut self.height)
|
||||
.speed(1.0)
|
||||
.prefix("Height:"),
|
||||
.prefix("Height: "),
|
||||
);
|
||||
ui.end_row();
|
||||
ui.checkbox(&mut self.show_axes[0], "x-Axis");
|
||||
|
||||
@@ -486,6 +486,10 @@ fn response_summary(response: &egui::Response, show_hovers: bool) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
if response.long_touched() {
|
||||
writeln!(new_info, "Clicked with long-press").ok();
|
||||
}
|
||||
|
||||
new_info
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user