From e31312cf7a6f1633e80a758902501bde3bd20cc3 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sun, 15 Aug 2021 17:26:48 +0200 Subject: [PATCH] Only move/resize windows with primary mouse button Closes #578 Closes #579 --- egui/src/containers/window.rs | 8 +++++++- egui/src/context.rs | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/egui/src/containers/window.rs b/egui/src/containers/window.rs index 2162367e..32cef350 100644 --- a/egui/src/containers/window.rs +++ b/egui/src/containers/window.rs @@ -533,6 +533,12 @@ fn interact( fn move_and_resize_window(ctx: &Context, window_interaction: &WindowInteraction) -> Option { window_interaction.set_cursor(ctx); + + // Only move/resize windows with primary mouse button: + if !ctx.input().pointer.primary_down() { + return None; + } + let pointer_pos = ctx.input().pointer.interact_pos()?; let mut rect = window_interaction.start_rect; // prevent drift @@ -586,7 +592,7 @@ fn window_interaction( if window_interaction.is_none() { if let Some(hover_window_interaction) = resize_hover(ctx, possible, area_layer_id, rect) { hover_window_interaction.set_cursor(ctx); - if ctx.input().pointer.any_pressed() && ctx.input().pointer.any_down() { + if ctx.input().pointer.any_pressed() && ctx.input().pointer.primary_down() { ctx.memory().interaction.drag_id = Some(id); ctx.memory().interaction.drag_is_window = true; window_interaction = Some(hover_window_interaction); diff --git a/egui/src/context.rs b/egui/src/context.rs index bc1dcbf7..2ae81b47 100644 --- a/egui/src/context.rs +++ b/egui/src/context.rs @@ -248,6 +248,7 @@ impl CtxRef { // This is needed because we do window interaction first (to prevent frame delay), // and then do content layout. if sense.drag + && self.input().pointer.primary_down() && (memory.interaction.drag_id.is_none() || memory.interaction.drag_is_window) {