Skip to content

Commit

Permalink
Only drag with primary pointer button
Browse files Browse the repository at this point in the history
  • Loading branch information
mankinskin committed Jul 27, 2021
1 parent 91cb092 commit 691fbe1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion egui/src/containers/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,10 @@ fn interact(

fn move_and_resize_window(ctx: &Context, window_interaction: &WindowInteraction) -> Option<Rect> {
window_interaction.set_cursor(ctx);
// only use primary clicks as window interaction
if !ctx.input().pointer.button_down(PointerButton::Primary) {
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 +590,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.button_down(PointerButton::Primary) {
ctx.memory().interaction.drag_id = Some(id);
ctx.memory().interaction.drag_is_window = true;
window_interaction = Some(hover_window_interaction);
Expand Down
2 changes: 1 addition & 1 deletion egui/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ impl CtxRef {
// the slider will steal the drag away from the window.
// This is needed because we do window interaction first (to prevent frame delay),
// and then do content layout.
if sense.drag
if sense.drag && self.input().pointer.button_down(PointerButton::Primary)
&& (memory.interaction.drag_id.is_none()
|| memory.interaction.drag_is_window)
{
Expand Down

0 comments on commit 691fbe1

Please sign in to comment.