improve detaching post its
This commit is contained in:
parent
bc7c2d6b6d
commit
381377d51a
|
|
@ -60,6 +60,7 @@ var is_dragged: bool = false:
|
||||||
is_dragged = dragged
|
is_dragged = dragged
|
||||||
z_index = int(dragged)
|
z_index = int(dragged)
|
||||||
|
|
||||||
|
var is_mouse_entered: bool = false
|
||||||
var mouse_offset: Vector2
|
var mouse_offset: Vector2
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
|
@ -118,13 +119,18 @@ func _on_focus_exited():
|
||||||
print(self, "is not focused")
|
print(self, "is not focused")
|
||||||
|
|
||||||
func _on_mouse_entered():
|
func _on_mouse_entered():
|
||||||
|
is_mouse_entered = true
|
||||||
if not Input.is_action_pressed("mouse_left"):
|
if not Input.is_action_pressed("mouse_left"):
|
||||||
|
if has_postit_attached():
|
||||||
|
if get_child(-1).highlighted:
|
||||||
|
return
|
||||||
highlighted = true
|
highlighted = true
|
||||||
if "handle_hover" in owner:
|
if "handle_hover" in owner:
|
||||||
owner.handle_hover(self)
|
owner.handle_hover(self)
|
||||||
|
|
||||||
func _on_mouse_exited():
|
func _on_mouse_exited():
|
||||||
highlighted = false
|
highlighted = false
|
||||||
|
is_mouse_entered = false
|
||||||
|
|
||||||
func _on_input_event(viewport, event, shape_idx):
|
func _on_input_event(viewport, event, shape_idx):
|
||||||
|
|
||||||
|
|
@ -134,8 +140,8 @@ func _on_input_event(viewport, event, shape_idx):
|
||||||
if event is InputEventMouseButton:
|
if event is InputEventMouseButton:
|
||||||
if event.button_index == MOUSE_BUTTON_LEFT:
|
if event.button_index == MOUSE_BUTTON_LEFT:
|
||||||
if is_dragable and "handle_mouse_button" in owner:
|
if is_dragable and "handle_mouse_button" in owner:
|
||||||
mouse_offset = (get_viewport().get_mouse_position() - position)
|
mouse_offset = (get_viewport().get_mouse_position() - position)
|
||||||
owner.handle_mouse_button(self, event)
|
if highlighted: owner.handle_mouse_button(self, event)
|
||||||
|
|
||||||
func _move_card():
|
func _move_card():
|
||||||
if is_dragged:
|
if is_dragged:
|
||||||
|
|
@ -147,3 +153,7 @@ func has_postit_attached() -> bool:
|
||||||
if child.get_meta("type") == "post-it":
|
if child.get_meta("type") == "post-it":
|
||||||
return true
|
return true
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
func check_hover():
|
||||||
|
if is_mouse_entered:
|
||||||
|
_on_mouse_entered()
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,8 @@ func _on_mouse_entered():
|
||||||
|
|
||||||
func _on_mouse_exited():
|
func _on_mouse_exited():
|
||||||
highlighted = false
|
highlighted = false
|
||||||
|
if is_postit_attached() and "check_hover" in get_parent():
|
||||||
|
get_parent().check_hover()
|
||||||
|
|
||||||
func _on_input_event(viewport, event, shape_idx):
|
func _on_input_event(viewport, event, shape_idx):
|
||||||
if event is InputEventMouseMotion:
|
if event is InputEventMouseMotion:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue