Доработка. Подсказка теперь отображает состояние включено/отключено
This commit is contained in:
17
scripts/switch.gd
Normal file
17
scripts/switch.gd
Normal file
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user