EguiGlium::on_event: take event by reference
Closes https://github.com/emilk/egui/issues/500
This commit is contained in:
parent
147e7a47aa
commit
9007890440
2 changed files with 9 additions and 9 deletions
|
@ -330,7 +330,7 @@ pub fn run(mut app: Box<dyn epi::App>, nativve_options: epi::NativeOptions) -> !
|
||||||
is_focused = new_focused;
|
is_focused = new_focused;
|
||||||
}
|
}
|
||||||
|
|
||||||
egui.on_event(event, control_flow);
|
egui.on_event(&event, control_flow);
|
||||||
|
|
||||||
display.gl_window().window().request_redraw(); // TODO: ask egui if the events warrants a repaint instead
|
display.gl_window().window().request_redraw(); // TODO: ask egui if the events warrants a repaint instead
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ impl GliumInputState {
|
||||||
|
|
||||||
pub fn input_to_egui(
|
pub fn input_to_egui(
|
||||||
pixels_per_point: f32,
|
pixels_per_point: f32,
|
||||||
event: glutin::event::WindowEvent<'_>,
|
event: &glutin::event::WindowEvent<'_>,
|
||||||
clipboard: Option<&mut ClipboardContext>,
|
clipboard: Option<&mut ClipboardContext>,
|
||||||
input_state: &mut GliumInputState,
|
input_state: &mut GliumInputState,
|
||||||
control_flow: &mut ControlFlow,
|
control_flow: &mut ControlFlow,
|
||||||
|
@ -73,15 +73,15 @@ pub fn input_to_egui(
|
||||||
match event {
|
match event {
|
||||||
WindowEvent::CloseRequested | WindowEvent::Destroyed => *control_flow = ControlFlow::Exit,
|
WindowEvent::CloseRequested | WindowEvent::Destroyed => *control_flow = ControlFlow::Exit,
|
||||||
WindowEvent::ScaleFactorChanged { scale_factor, .. } => {
|
WindowEvent::ScaleFactorChanged { scale_factor, .. } => {
|
||||||
input_state.raw.pixels_per_point = Some(scale_factor as f32);
|
input_state.raw.pixels_per_point = Some(*scale_factor as f32);
|
||||||
}
|
}
|
||||||
WindowEvent::MouseInput { state, button, .. } => {
|
WindowEvent::MouseInput { state, button, .. } => {
|
||||||
if let Some(pos_in_points) = input_state.pointer_pos_in_points {
|
if let Some(pos_in_points) = input_state.pointer_pos_in_points {
|
||||||
if let Some(button) = translate_mouse_button(button) {
|
if let Some(button) = translate_mouse_button(*button) {
|
||||||
input_state.raw.events.push(egui::Event::PointerButton {
|
input_state.raw.events.push(egui::Event::PointerButton {
|
||||||
pos: pos_in_points,
|
pos: pos_in_points,
|
||||||
button,
|
button,
|
||||||
pressed: state == glutin::event::ElementState::Pressed,
|
pressed: *state == glutin::event::ElementState::Pressed,
|
||||||
modifiers: input_state.raw.modifiers,
|
modifiers: input_state.raw.modifiers,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ pub fn input_to_egui(
|
||||||
input_state.raw.events.push(egui::Event::PointerGone);
|
input_state.raw.events.push(egui::Event::PointerGone);
|
||||||
}
|
}
|
||||||
WindowEvent::ReceivedCharacter(ch) => {
|
WindowEvent::ReceivedCharacter(ch) => {
|
||||||
if is_printable_char(ch)
|
if is_printable_char(*ch)
|
||||||
&& !input_state.raw.modifiers.ctrl
|
&& !input_state.raw.modifiers.ctrl
|
||||||
&& !input_state.raw.modifiers.mac_cmd
|
&& !input_state.raw.modifiers.mac_cmd
|
||||||
{
|
{
|
||||||
|
@ -180,7 +180,7 @@ pub fn input_to_egui(
|
||||||
input_state.raw.modifiers = Modifiers::default();
|
input_state.raw.modifiers = Modifiers::default();
|
||||||
}
|
}
|
||||||
WindowEvent::MouseWheel { delta, .. } => {
|
WindowEvent::MouseWheel { delta, .. } => {
|
||||||
let mut delta = match delta {
|
let mut delta = match *delta {
|
||||||
glutin::event::MouseScrollDelta::LineDelta(x, y) => {
|
glutin::event::MouseScrollDelta::LineDelta(x, y) => {
|
||||||
let line_height = 8.0; // magic value!
|
let line_height = 8.0; // magic value!
|
||||||
vec2(x, y) * line_height
|
vec2(x, y) * line_height
|
||||||
|
@ -484,12 +484,12 @@ impl EguiGlium {
|
||||||
|
|
||||||
pub fn on_event(
|
pub fn on_event(
|
||||||
&mut self,
|
&mut self,
|
||||||
event: glium::glutin::event::WindowEvent<'_>,
|
event: &glium::glutin::event::WindowEvent<'_>,
|
||||||
control_flow: &mut glium::glutin::event_loop::ControlFlow,
|
control_flow: &mut glium::glutin::event_loop::ControlFlow,
|
||||||
) {
|
) {
|
||||||
crate::input_to_egui(
|
crate::input_to_egui(
|
||||||
self.egui_ctx.pixels_per_point(),
|
self.egui_ctx.pixels_per_point(),
|
||||||
event,
|
&event,
|
||||||
self.clipboard.as_mut(),
|
self.clipboard.as_mut(),
|
||||||
&mut self.input_state,
|
&mut self.input_state,
|
||||||
control_flow,
|
control_flow,
|
||||||
|
|
Loading…
Reference in a new issue