diff --git a/egui_demo_lib/src/apps/demo/plot_demo.rs b/egui_demo_lib/src/apps/demo/plot_demo.rs index 452f9fcb..df457cf3 100644 --- a/egui_demo_lib/src/apps/demo/plot_demo.rs +++ b/egui_demo_lib/src/apps/demo/plot_demo.rs @@ -95,7 +95,15 @@ impl PlotDemo { }); }); - ui.label("Drag to pan, ctrl + scroll to zoom. Double-click to reset view."); + ui.label("Pan by dragging, or scroll (+ shift = horizontal)."); + if cfg!(target_arch = "wasm32") { + ui.label("Zoom with ctrl / ⌘ + mouse wheel, or with pinch gesture."); + } else if cfg!(target_os = "macos") { + ui.label("Zoom with ctrl / ⌘ + scroll."); + } else { + ui.label("Zoom with ctrl + scroll."); + } + ui.label("Reset view with double-click."); } fn circle(&self) -> Curve { diff --git a/egui_glium/CHANGELOG.md b/egui_glium/CHANGELOG.md index 23e09ac3..cbe94c48 100644 --- a/egui_glium/CHANGELOG.md +++ b/egui_glium/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to the `egui_glium` integration will be noted in this file. ## Unreleased +* [Fix modifier key for zoom with mouse wheel on Mac](https://github.com/emilk/egui/issues/401) ## 0.12.0 - 2021-05-10 diff --git a/egui_glium/src/lib.rs b/egui_glium/src/lib.rs index 6666545a..da1a0c6f 100644 --- a/egui_glium/src/lib.rs +++ b/egui_glium/src/lib.rs @@ -188,7 +188,7 @@ pub fn input_to_egui( delta.x *= -1.0; } - if input_state.raw.modifiers.ctrl { + if input_state.raw.modifiers.ctrl || input_state.raw.modifiers.command { // Treat as zoom instead: input_state.raw.zoom_delta *= (delta.y / 200.0).exp(); } else { diff --git a/egui_web/src/lib.rs b/egui_web/src/lib.rs index f5f260f6..b78a00bd 100644 --- a/egui_web/src/lib.rs +++ b/egui_web/src/lib.rs @@ -1053,7 +1053,10 @@ fn install_canvas_events(runner_ref: &AppRunnerRef) -> Result<(), JsValue> { let delta = -scroll_multiplier * egui::Vec2::new(event.delta_x() as f32, event.delta_y() as f32); - if event.ctrl_key() { + // Report a zoom event in case CTRL (on Windows or Linux) or CMD (on Mac) is pressed. + // This if-statement is equivalent to how `Modifiers.command` is determined in + // `modifiers_from_event()`, but we cannot directly use that fn for a `WheelEvent`. + if event.ctrl_key() || event.meta_key() { runner_lock.input.raw.zoom_delta *= (delta.y / 200.0).exp(); } else { runner_lock.input.raw.scroll_delta += delta;