Skip to content

Commit 042e1ad

Browse files
authored
Better documentation for Event::Zoom (#4778)
* Closes #4777 Also add this to the 0.28 migration guide.
1 parent 8bf498d commit 042e1ad

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Changes since the last release can be found at <https://github.com/emilk/egui/co
2222
* `Ui::new` and `ui.child_ui` now takes a new parameter for the `UiStack` ([#4588](https://github.com/emilk/egui/pull/4588))
2323
* The `extra_asserts` and `extra_debug_asserts` feature flags have been removed ([#4478](https://github.com/emilk/egui/pull/4478))
2424
* Remove `Event::Scroll` and handle it in egui. Use `Event::MouseWheel` instead ([#4524](https://github.com/emilk/egui/pull/4524))
25+
* `Event::Zoom` is no longer emitted on ctrl+scroll. Use `InputState::smooth_scroll_delta` instead ([#4524](https://github.com/emilk/egui/pull/4524))
2526
* `ui.set_enabled` and `set_visbile` have been deprecated ([#4614](https://github.com/emilk/egui/pull/4614))
2627
* `DragValue::clamp_range` renamed to `range` (([#4728](https://github.com/emilk/egui/pull/4728))
2728

crates/egui/src/data/input.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,16 @@ pub enum Event {
426426
/// On touch-up first send `PointerButton{pressed: false, …}` followed by `PointerLeft`.
427427
PointerGone,
428428

429-
/// Zoom scale factor this frame (e.g. from ctrl-scroll or pinch gesture).
429+
/// Zoom scale factor this frame (e.g. from a pinch gesture).
430+
///
430431
/// * `zoom = 1`: no change.
431432
/// * `zoom < 1`: pinch together
432433
/// * `zoom > 1`: pinch spread
434+
///
435+
/// Note that egui also implement zooming by holding `Ctrl` and scrolling the mouse wheel,
436+
/// so integration need NOT emit this `Zoom` event in those cases, just [`Self::MouseWheel`].
437+
///
438+
/// As a user, check [`crate::InputState::smooth_scroll_delta`] to see if the user did any zooming this frame.
433439
Zoom(f32),
434440

435441
/// IME Event

crates/egui/src/input_state.rs

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ const MAX_DOUBLE_CLICK_DELAY: f64 = 0.3; // TODO(emilk): move to settings
2727

2828
/// Input state that egui updates each frame.
2929
///
30+
/// You can access this with [`crate::Context::input`].
31+
///
3032
/// You can check if `egui` is using the inputs using
3133
/// [`crate::Context::wants_pointer_input`] and [`crate::Context::wants_keyboard_input`].
3234
#[derive(Clone, Debug)]

0 commit comments

Comments
 (0)