Skip to content

Commit

Permalink
Only move/resize windows with primary mouse button
Browse files Browse the repository at this point in the history
Closes emilk#578
Closes emilk#579
  • Loading branch information
emilk authored and mankinskin committed Sep 29, 2021
1 parent b0db16f commit 99f116e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion egui/src/containers/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,12 @@ fn interact(

fn move_and_resize_window(ctx: &Context, window_interaction: &WindowInteraction) -> Option<Rect> {
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

Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions egui/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 99f116e

Please sign in to comment.