34 lines
701 B
GDScript
34 lines
701 B
GDScript
extends Control
|
|
|
|
signal text_changed
|
|
signal key_pressed
|
|
|
|
@onready var main_keys: HFlowContainer = $MainKeys
|
|
@onready var text_label: Label = $TextLabel
|
|
|
|
@export var text: String = "":
|
|
set(value):
|
|
text = value
|
|
text_label.text = text
|
|
text_changed.emit()
|
|
|
|
var shifting: bool = true
|
|
|
|
func _ready() -> void:
|
|
for key: Button in main_keys.get_children():
|
|
key.connect("pressed", func():
|
|
key_pressed.emit()
|
|
match key.name:
|
|
"UShift":
|
|
shifting = !shifting
|
|
for i_key: Button in main_keys.get_children():
|
|
if shifting:
|
|
i_key.text = i_key.text.to_upper()
|
|
else:
|
|
i_key.text = i_key.text.to_lower()
|
|
"USpace":
|
|
text += " "
|
|
_:
|
|
text += key.text
|
|
)
|