improving parsing and passing of mouse events
This commit is contained in:
parent
1dae8286cf
commit
ef93aafd9e
|
|
@ -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():
|
||||
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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue