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()
|
||||
if sticky and sticky.highlighted:
|
||||
return
|
||||
var parent = get_parent()
|
||||
if parent and parent.has_method("handle_hover"):
|
||||
parent.handle_hover(self)
|
||||
var board = _get_board()
|
||||
if board:
|
||||
board.handle_hover(self)
|
||||
|
||||
func _on_mouse_exited():
|
||||
highlighted = false
|
||||
|
|
@ -228,10 +228,10 @@ func _on_mouse_exited():
|
|||
|
||||
func _on_input_event(_viewport, event, _shape_idx):
|
||||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
|
||||
var parent = get_parent()
|
||||
if parent and parent.has_method("handle_mouse_button") and highlighted:
|
||||
var board = _get_board()
|
||||
if board and highlighted:
|
||||
mouse_offset = get_viewport().get_mouse_position() - position
|
||||
parent.handle_mouse_button(event, self)
|
||||
board.handle_mouse_button(event, self)
|
||||
|
||||
func _move_card():
|
||||
if is_dragged:
|
||||
|
|
@ -341,11 +341,16 @@ func get_last_exchanged_sticky() -> StickyNote:
|
|||
|
||||
## Cards always drop back to board dropzone
|
||||
func find_drop_target() -> Node:
|
||||
var parent = get_parent()
|
||||
# Walk up tree to find CardBoard
|
||||
while parent:
|
||||
if parent is CardBoard:
|
||||
return parent
|
||||
parent = parent.get_parent()
|
||||
# Fallback to immediate parent
|
||||
return get_parent()
|
||||
return _get_board()
|
||||
|
||||
|
||||
# === HELPER FUNCTIONS ===
|
||||
|
||||
## Walks up the scene tree to find the CardBoard
|
||||
func _get_board() -> CardBoard:
|
||||
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()
|
||||
|
||||
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)
|
||||
|
||||
func _on_mouse_exited():
|
||||
|
|
@ -137,7 +137,7 @@ func _on_area_exit(area: Area2D):
|
|||
panel.collapse_gap()
|
||||
|
||||
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:
|
||||
mouse_offset = get_viewport().get_mouse_position() - global_position
|
||||
current_handle.handle_mouse_button(event, self)
|
||||
|
|
|
|||
Loading…
Reference in New Issue