Files
uarep-ctl/scripts/switch.gd

18 lines
500 B
GDScript

extends CheckButton
@export var off_tip: String = '(отключено)'
@export var on_tip: String = '(включено)'
func _ready() -> void:
if not (tooltip_text.contains(off_tip) or tooltip_text.contains(on_tip)):
tooltip_text += ' '
tooltip_text += on_tip if button_pressed else off_tip
connect('toggled', _on_toggled)
func _on_toggled(state: bool):
var s = tooltip_text
tooltip_text = s.replace(off_tip, on_tip) if state else s.replace(on_tip, off_tip)