extends Button signal value_changed export var corner_radius = 5 var normal_style = StyleBoxFlat.new() var outline_style = StyleBoxFlat.new() var value = 0 # Called when the node enters the scene tree for the first time. func _ready(): connect("pressed", self, "_on_Pix_pressed") normal_style.set_corner_radius_all(corner_radius) outline_style.set_corner_radius_all(corner_radius) outline_style.set_border_width_all(5) outline_style.set_border_color(Color.webpurple) # Set default style _on_Pix_pressed(true) func _on_Pix_pressed(bypass: bool = false): if (!bypass): value = (value + 1) % 2 if value == 0: set_color(Color.blanchedalmond) else: set_color(Color.black) if (!bypass): emit_signal("value_changed") func set_color(color): normal_style.set_bg_color(color) set("custom_styles/normal", normal_style) outline_style.set_bg_color(color) set("custom_styles/focus", outline_style) set("custom_styles/hover", outline_style)