fix: card hover transform
This commit is contained in:
parent
39ae7a9d1a
commit
e86ce44583
|
|
@ -217,9 +217,9 @@ func _on_mouse_entered() -> void:
|
||||||
var sticky = get_attached_sticky_note()
|
var sticky = get_attached_sticky_note()
|
||||||
if sticky and sticky.highlighted:
|
if sticky and sticky.highlighted:
|
||||||
return
|
return
|
||||||
var parent = get_parent()
|
var board = _get_board()
|
||||||
if parent and parent.has_method("handle_hover"):
|
if board:
|
||||||
parent.handle_hover(self)
|
board.handle_hover(self)
|
||||||
|
|
||||||
func _on_mouse_exited():
|
func _on_mouse_exited():
|
||||||
highlighted = false
|
highlighted = false
|
||||||
|
|
@ -228,10 +228,10 @@ func _on_mouse_exited():
|
||||||
|
|
||||||
func _on_input_event(_viewport, event, _shape_idx):
|
func _on_input_event(_viewport, event, _shape_idx):
|
||||||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
|
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
|
||||||
var parent = get_parent()
|
var board = _get_board()
|
||||||
if parent and parent.has_method("handle_mouse_button") and highlighted:
|
if board and highlighted:
|
||||||
mouse_offset = get_viewport().get_mouse_position() - position
|
mouse_offset = get_viewport().get_mouse_position() - position
|
||||||
parent.handle_mouse_button(event, self)
|
board.handle_mouse_button(event, self)
|
||||||
|
|
||||||
func _move_card():
|
func _move_card():
|
||||||
if is_dragged:
|
if is_dragged:
|
||||||
|
|
@ -341,11 +341,16 @@ func get_last_exchanged_sticky() -> StickyNote:
|
||||||
|
|
||||||
## Cards always drop back to board dropzone
|
## Cards always drop back to board dropzone
|
||||||
func find_drop_target() -> Node:
|
func find_drop_target() -> Node:
|
||||||
var parent = get_parent()
|
return _get_board()
|
||||||
# Walk up tree to find CardBoard
|
|
||||||
while parent:
|
|
||||||
if parent is CardBoard:
|
# === HELPER FUNCTIONS ===
|
||||||
return parent
|
|
||||||
parent = parent.get_parent()
|
## Walks up the scene tree to find the CardBoard
|
||||||
# Fallback to immediate parent
|
func _get_board() -> CardBoard:
|
||||||
return get_parent()
|
var node = get_parent()
|
||||||
|
while node:
|
||||||
|
if node is CardBoard:
|
||||||
|
return node
|
||||||
|
node = node.get_parent()
|
||||||
|
return null
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ func _process(delta: float) -> void:
|
||||||
_move_sticky_note()
|
_move_sticky_note()
|
||||||
|
|
||||||
func _on_mouse_entered():
|
func _on_mouse_entered():
|
||||||
if not Input.is_action_pressed("mouse_left") and "handle_hover" in current_handle:
|
if not Input.is_action_pressed("mouse_left") and current_handle and current_handle.has_method("handle_hover"):
|
||||||
current_handle.handle_hover(self)
|
current_handle.handle_hover(self)
|
||||||
|
|
||||||
func _on_mouse_exited():
|
func _on_mouse_exited():
|
||||||
|
|
@ -137,7 +137,7 @@ func _on_area_exit(area: Area2D):
|
||||||
panel.collapse_gap()
|
panel.collapse_gap()
|
||||||
|
|
||||||
func _on_input_event(_viewport, event, _shape_idx):
|
func _on_input_event(_viewport, event, _shape_idx):
|
||||||
if event is InputEventMouseButton and "handle_mouse_button" in current_handle:
|
if event is InputEventMouseButton and current_handle and current_handle.has_method("handle_mouse_button"):
|
||||||
if (event.button_index == MOUSE_BUTTON_LEFT and event.pressed) or event.button_index == MOUSE_BUTTON_RIGHT:
|
if (event.button_index == MOUSE_BUTTON_LEFT and event.pressed) or event.button_index == MOUSE_BUTTON_RIGHT:
|
||||||
mouse_offset = get_viewport().get_mouse_position() - global_position
|
mouse_offset = get_viewport().get_mouse_position() - global_position
|
||||||
current_handle.handle_mouse_button(event, self)
|
current_handle.handle_mouse_button(event, self)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue