Skip to content

Commit dc13a04

Browse files
committed
Only drag with primary pointer button
1 parent 68f4957 commit dc13a04

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

egui/src/containers/window.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,10 @@ fn interact(
522522

523523
fn move_and_resize_window(ctx: &Context, window_interaction: &WindowInteraction) -> Option<Rect> {
524524
window_interaction.set_cursor(ctx);
525+
// only use primary clicks as window interaction
526+
if !ctx.input().pointer.button_down(PointerButton::Primary) {
527+
return None;
528+
}
525529
let pointer_pos = ctx.input().pointer.interact_pos()?;
526530
let mut rect = window_interaction.start_rect; // prevent drift
527531

@@ -575,7 +579,7 @@ fn window_interaction(
575579
if window_interaction.is_none() {
576580
if let Some(hover_window_interaction) = resize_hover(ctx, possible, area_layer_id, rect) {
577581
hover_window_interaction.set_cursor(ctx);
578-
if ctx.input().pointer.any_pressed() && ctx.input().pointer.any_down() {
582+
if ctx.input().pointer.any_pressed() && ctx.input().pointer.button_down(PointerButton::Primary) {
579583
ctx.memory().interaction.drag_id = Some(id);
580584
ctx.memory().interaction.drag_is_window = true;
581585
window_interaction = Some(hover_window_interaction);

egui/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ impl CtxRef {
248248
// the slider will steal the drag away from the window.
249249
// This is needed because we do window interaction first (to prevent frame delay),
250250
// and then do content layout.
251-
if sense.drag
251+
if sense.drag && self.input().pointer.button_down(PointerButton::Primary)
252252
&& (memory.interaction.drag_id.is_none()
253253
|| memory.interaction.drag_is_window)
254254
{

0 commit comments

Comments
 (0)