diff --git a/src/logic-scenes/board/card.gd b/src/logic-scenes/board/card.gd index ba79b64..0516a92 100644 --- a/src/logic-scenes/board/card.gd +++ b/src/logic-scenes/board/card.gd @@ -49,6 +49,7 @@ var scale_tween @export var voice_line: AudioStream = null @export var is_dragable: bool = false +var is_dragged: bool = false func _ready(): _handle_wiggle(0) @@ -91,12 +92,22 @@ func _on_focus_exited(): print(self, "is not focused") func _on_mouse_entered(): - highlighted = true + if not Input.is_action_pressed("mouse_left"): + highlighted = true + if "handle_hover" in owner: + owner.handle_hover(self) func _on_mouse_exited(): highlighted = false func _on_input_event(viewport, event, shape_idx): - if event is InputEventMouseMotion and Input.is_action_pressed("mouse_left") and is_dragable: + if event is InputEventMouseMotion and is_dragged: position += event.relative + + if event is InputEventMouseButton: + if event.button_index == MOUSE_BUTTON_LEFT: + if is_dragable: + is_dragged = event.pressed + if "handle_mouse_button" in owner: + owner.handle_mouse_button(self, event) diff --git a/src/logic-scenes/board/post-it.gd b/src/logic-scenes/board/post-it.gd index b5cad59..c9f705c 100644 --- a/src/logic-scenes/board/post-it.gd +++ b/src/logic-scenes/board/post-it.gd @@ -46,6 +46,7 @@ var modulate_tween @export var voice_line: AudioStream = null @export var is_dragable: bool = false +var is_dragged = false func _ready() -> void: $Content/Label.text = self.text @@ -67,12 +68,21 @@ func _on_focus_exited(): print(self, "is not focused") func _on_mouse_entered(): - #owner.grab_highlight(self) - highlighted = true + if not Input.is_action_pressed("mouse_left"): + highlighted = true + if "handle_hover" in owner: + owner.handle_hover(self) func _on_mouse_exited(): highlighted = false func _on_input_event(viewport, event, shape_idx): - if event is InputEventMouseMotion and Input.is_action_pressed("mouse_left") and is_dragable: + if event is InputEventMouseMotion and is_dragged: position += event.relative + + if event is InputEventMouseButton: + if event.button_index == MOUSE_BUTTON_LEFT: + if is_dragable: + is_dragged = event.pressed + if "handle_mouse_button" in owner: + owner.handle_mouse_button(self, event)