diff --git a/eframe/src/web/input.rs b/eframe/src/web/input.rs index 5d1b00cf..388e2ca9 100644 --- a/eframe/src/web/input.rs +++ b/eframe/src/web/input.rs @@ -14,6 +14,8 @@ pub fn button_from_mouse_event(event: &web_sys::MouseEvent) -> Option Some(egui::PointerButton::Primary), 1 => Some(egui::PointerButton::Middle), 2 => Some(egui::PointerButton::Secondary), + 3 => Some(egui::PointerButton::Extra1), + 4 => Some(egui::PointerButton::Extra2), _ => None, } } diff --git a/egui-winit/src/lib.rs b/egui-winit/src/lib.rs index 47129ac2..4286af84 100644 --- a/egui-winit/src/lib.rs +++ b/egui-winit/src/lib.rs @@ -542,6 +542,8 @@ fn translate_mouse_button(button: winit::event::MouseButton) -> Option Some(egui::PointerButton::Primary), winit::event::MouseButton::Right => Some(egui::PointerButton::Secondary), winit::event::MouseButton::Middle => Some(egui::PointerButton::Middle), + winit::event::MouseButton::Other(1) => Some(egui::PointerButton::Extra1), + winit::event::MouseButton::Other(2) => Some(egui::PointerButton::Extra2), winit::event::MouseButton::Other(_) => None, } } diff --git a/egui/src/data/input.rs b/egui/src/data/input.rs index c689179d..adfa7db9 100644 --- a/egui/src/data/input.rs +++ b/egui/src/data/input.rs @@ -254,10 +254,14 @@ pub enum PointerButton { Secondary = 1, /// The tertiary mouse button is usually the middle mouse button (e.g. clicking the scroll wheel). Middle = 2, + /// The first extra mouse button on some mice. In web typically corresponds to the Browser back button. + Extra1 = 3, + /// The second extra mouse button on some mice. In web typically corresponds to the Browser forward button. + Extra2 = 4, } /// Number of pointer buttons supported by egui, i.e. the number of possible states of [`PointerButton`]. -pub const NUM_POINTER_BUTTONS: usize = 3; +pub const NUM_POINTER_BUTTONS: usize = 5; /// State of the modifier keys. These must be fed to egui. /// diff --git a/egui/src/response.rs b/egui/src/response.rs index ca3f3e02..57416154 100644 --- a/egui/src/response.rs +++ b/egui/src/response.rs @@ -557,16 +557,22 @@ impl Response { self.clicked[0] || other.clicked[0], self.clicked[1] || other.clicked[1], self.clicked[2] || other.clicked[2], + self.clicked[3] || other.clicked[3], + self.clicked[4] || other.clicked[4], ], double_clicked: [ self.double_clicked[0] || other.double_clicked[0], self.double_clicked[1] || other.double_clicked[1], self.double_clicked[2] || other.double_clicked[2], + self.double_clicked[3] || other.double_clicked[3], + self.double_clicked[4] || other.double_clicked[4], ], triple_clicked: [ self.triple_clicked[0] || other.triple_clicked[0], self.triple_clicked[1] || other.triple_clicked[1], self.triple_clicked[2] || other.triple_clicked[2], + self.triple_clicked[3] || other.triple_clicked[3], + self.triple_clicked[4] || other.triple_clicked[4], ], dragged: self.dragged || other.dragged, drag_released: self.drag_released || other.drag_released, diff --git a/egui_demo_lib/src/demo/tests.rs b/egui_demo_lib/src/demo/tests.rs index 94cd3667..d4a849bd 100644 --- a/egui_demo_lib/src/demo/tests.rs +++ b/egui_demo_lib/src/demo/tests.rs @@ -341,6 +341,8 @@ impl super::View for InputTest { egui::PointerButton::Primary, egui::PointerButton::Secondary, egui::PointerButton::Middle, + egui::PointerButton::Extra1, + egui::PointerButton::Extra2, ] { if response.clicked_by(button) { new_info += &format!("Clicked by {:?} button\n", button);