Added Extra1 & Extra2 pointer buttons (#1603)
Extra1 is usually extra back button on most mice & Extra2 is usually extra forward button.
This commit is contained in:
parent
9624de6c41
commit
d850b47f9e
5 changed files with 17 additions and 1 deletions
|
@ -14,6 +14,8 @@ pub fn button_from_mouse_event(event: &web_sys::MouseEvent) -> Option<egui::Poin
|
|||
0 => 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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -542,6 +542,8 @@ fn translate_mouse_button(button: winit::event::MouseButton) -> Option<egui::Poi
|
|||
winit::event::MouseButton::Left => 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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
///
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue