From d3ea90f5efe5a2b20826f8896fbaa5636f2646d7 Mon Sep 17 00:00:00 2001 From: rustbasic <127506429+rustbasic@users.noreply.github.com> Date: Fri, 31 May 2024 22:22:46 +0900 Subject: [PATCH] Fix dragging of `custom_window_frame` on Windows (#4592) Fix: example `custom_window_frame` Sending `ViewportCommand::StartDrag` when the secondary button is clicked in Windows will disable drag, and drag will not be possible with the primary button afterwards. So in the example `custom_window_frame`, modified to use `dragged_by(PointerButton::Primary)` instead of `is_pointer_button_down_on()`. --- examples/custom_window_frame/src/main.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/custom_window_frame/src/main.rs b/examples/custom_window_frame/src/main.rs index bd29788a..ef6df49d 100644 --- a/examples/custom_window_frame/src/main.rs +++ b/examples/custom_window_frame/src/main.rs @@ -81,7 +81,11 @@ fn title_bar_ui(ui: &mut egui::Ui, title_bar_rect: eframe::epaint::Rect, title: let painter = ui.painter(); - let title_bar_response = ui.interact(title_bar_rect, Id::new("title_bar"), Sense::click()); + let title_bar_response = ui.interact( + title_bar_rect, + Id::new("title_bar"), + Sense::click_and_drag(), + ); // Paint the title: painter.text( @@ -108,7 +112,7 @@ fn title_bar_ui(ui: &mut egui::Ui, title_bar_rect: eframe::epaint::Rect, title: .send_viewport_cmd(ViewportCommand::Maximized(!is_maximized)); } - if title_bar_response.is_pointer_button_down_on() { + if title_bar_response.dragged_by(PointerButton::Primary) { ui.ctx().send_viewport_cmd(ViewportCommand::StartDrag); }