adding state handling to post_its
This commit is contained in:
parent
930538519f
commit
7fb7be47a8
|
|
@ -6,6 +6,8 @@ var sibling
|
|||
var shift_tween
|
||||
var modulate_tween
|
||||
|
||||
var on_stage = false
|
||||
|
||||
@export var text: String = "" :
|
||||
set (value):
|
||||
if is_inside_tree() or Engine.is_editor_hint():
|
||||
|
|
@ -60,8 +62,8 @@ func replace_with(postit: PostIt):
|
|||
self.sibling = postit.sibling
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
_move_post_it()
|
||||
|
||||
if on_stage:
|
||||
_move_post_it()
|
||||
|
||||
func _on_focus_entered():
|
||||
print(self, "is focused")
|
||||
|
|
@ -70,7 +72,7 @@ func _on_focus_exited():
|
|||
print(self, "is not focused")
|
||||
|
||||
func _on_mouse_entered():
|
||||
if not Input.is_action_pressed("mouse_left"):
|
||||
if on_stage and not Input.is_action_pressed("mouse_left"):
|
||||
highlighted = true
|
||||
if "handle_hover" in owner:
|
||||
owner.handle_hover(self)
|
||||
|
|
@ -79,13 +81,14 @@ func _on_mouse_exited():
|
|||
highlighted = false
|
||||
|
||||
func _on_input_event(viewport, event, shape_idx):
|
||||
if event is InputEventMouseMotion:
|
||||
_move_post_it()
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_LEFT:
|
||||
if is_dragable and "handle_mouse_button" in owner:
|
||||
owner.handle_mouse_button(self, event)
|
||||
if on_stage:
|
||||
if event is InputEventMouseMotion:
|
||||
_move_post_it()
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_LEFT:
|
||||
if is_dragable and "handle_mouse_button" in owner:
|
||||
owner.handle_mouse_button(self, event)
|
||||
|
||||
func _move_post_it():
|
||||
if is_dragged:
|
||||
|
|
|
|||
Loading…
Reference in New Issue