challenge-editor/scene/tool/tool_button.gd
2024-11-27 20:28:51 +08:00

43 lines
1.1 KiB
GDScript

extends Button
class_name ToolButton
var is_mouse_enter:bool=false
var is_down:bool=false
func on_button_down() -> void:
is_down=true
get_parent().modulate=Color(0.5,0.5,0.5,1)
pass # Replace with function body.
func on_button_up() -> void:
is_down=false
if not is_mouse_enter:
get_parent().modulate=Color(1,1,1,1)
else:
get_parent().modulate=Color(0.8,0.8,0.8,1)
pass # Replace with function body.ion body.
static func static_on_button_down(canvas:CanvasItem) -> void:
canvas.modulate=Color(0.5,0.5,0.5,1)
pass # Replace with function body.
static func static_on_button_up(canvas:CanvasItem) -> void:
canvas.modulate=Color(1,1,1,1)
pass # Replace with function body.ion body.
func disable(is_disable:bool):
disabled=is_disable
if is_disable:
get_parent().modulate=Color(0.5,0.5,0.5,1)
else:
get_parent().modulate=Color(1,1,1,1)
func _on_mouse_entered() -> void:
is_mouse_enter=true
if not is_down:
get_parent().modulate=Color(0.8,0.8,0.8,1)
pass # Replace with function body.
func _on_mouse_exited() -> void:
is_mouse_enter=false
if not is_down:
get_parent().modulate=Color(1,1,1,1)
pass # Replace with function body.