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()`.
This commit is contained in:
rustbasic 2024-05-31 22:22:46 +09:00 committed by GitHub
parent df8b9c2d75
commit d3ea90f5ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 2 deletions

View File

@ -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);
}