improving parsing and passing of mouse events
This commit is contained in:
parent
bbec8c4f25
commit
8307380bf0
|
|
@ -51,6 +51,7 @@ var scale_tween
|
||||||
|
|
||||||
@export var voice_line: AudioStream = null
|
@export var voice_line: AudioStream = null
|
||||||
@export var is_dragable: bool = false
|
@export var is_dragable: bool = false
|
||||||
|
var is_dragged: bool = false
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
|
||||||
|
|
@ -96,12 +97,22 @@ func _on_focus_exited():
|
||||||
print(self, "is not focused")
|
print(self, "is not focused")
|
||||||
|
|
||||||
func _on_mouse_entered():
|
func _on_mouse_entered():
|
||||||
|
if not Input.is_action_pressed("mouse_left"):
|
||||||
highlighted = true
|
highlighted = true
|
||||||
|
if "handle_hover" in owner:
|
||||||
|
owner.handle_hover(self)
|
||||||
|
|
||||||
func _on_mouse_exited():
|
func _on_mouse_exited():
|
||||||
highlighted = false
|
highlighted = false
|
||||||
|
|
||||||
func _on_input_event(viewport, event, shape_idx):
|
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
|
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)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ var modulate_tween
|
||||||
|
|
||||||
@export var voice_line: AudioStream = null
|
@export var voice_line: AudioStream = null
|
||||||
@export var is_dragable: bool = false
|
@export var is_dragable: bool = false
|
||||||
|
var is_dragged = false
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
$Content/Label.text = self.text
|
$Content/Label.text = self.text
|
||||||
|
|
@ -63,12 +64,21 @@ func _on_focus_exited():
|
||||||
print(self, "is not focused")
|
print(self, "is not focused")
|
||||||
|
|
||||||
func _on_mouse_entered():
|
func _on_mouse_entered():
|
||||||
#owner.grab_highlight(self)
|
if not Input.is_action_pressed("mouse_left"):
|
||||||
highlighted = true
|
highlighted = true
|
||||||
|
if "handle_hover" in owner:
|
||||||
|
owner.handle_hover(self)
|
||||||
|
|
||||||
func _on_mouse_exited():
|
func _on_mouse_exited():
|
||||||
highlighted = false
|
highlighted = false
|
||||||
|
|
||||||
func _on_input_event(viewport, event, shape_idx):
|
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
|
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