From 869568db3729b89bfa98775980c015b629293c15 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 11 Dec 2022 12:00:48 +0100 Subject: [PATCH] Fix mouse pointer handling when dragging an image. --- game/menu/Menu.tscn | 22 +++++++++++----------- game/sort/ScrollImageContainer.gd | 7 +++++-- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/game/menu/Menu.tscn b/game/menu/Menu.tscn index 88f0d2d..9dfb193 100644 --- a/game/menu/Menu.tscn +++ b/game/menu/Menu.tscn @@ -7,26 +7,26 @@ anchor_right = 1.0 anchor_bottom = 1.0 [node name="VBoxContainer" type="VBoxContainer" parent="."] -margin_right = 600.0 -margin_bottom = 600.0 +margin_right = 900.0 +margin_bottom = 1000.0 custom_constants/separation = 24 alignment = 1 [node name="Sort" type="Button" parent="VBoxContainer"] -margin_top = 246.0 -margin_right = 600.0 -margin_bottom = 266.0 +margin_top = 446.0 +margin_right = 900.0 +margin_bottom = 466.0 text = "Sort" [node name="Settings" type="Button" parent="VBoxContainer"] -margin_top = 290.0 -margin_right = 600.0 -margin_bottom = 310.0 +margin_top = 490.0 +margin_right = 900.0 +margin_bottom = 510.0 text = "Settings" [node name="Exit" type="Button" parent="VBoxContainer"] -margin_top = 334.0 -margin_right = 600.0 -margin_bottom = 354.0 +margin_top = 534.0 +margin_right = 900.0 +margin_bottom = 554.0 text = "Exit" script = ExtResource( 1 ) diff --git a/game/sort/ScrollImageContainer.gd b/game/sort/ScrollImageContainer.gd index ec67c88..757666b 100644 --- a/game/sort/ScrollImageContainer.gd +++ b/game/sort/ScrollImageContainer.gd @@ -38,15 +38,18 @@ func _gui_input(event: InputEvent) -> void: elif iemb.button_index == BUTTON_WHEEL_DOWN: _zoom_slider.value -= 0.03 else: + if mouse_down && mouse_pointer != iemb.button_index: + return + mouse_down = iemb.pressed - mouse_pointer == event.button_index + mouse_pointer == iemb.button_index accept_event() elif event is InputEventMouseMotion: var iemm : InputEventMouseMotion = event - if !mouse_down || mouse_pointer != event.device: + if !mouse_down: return hscrollbar.value -= iemm.relative.x