online multiplayer chess game (note server currently down)
Diffstat (limited to 'ui/chat/textedit.gd')
-rw-r--r--ui/chat/textedit.gd18
1 files changed, 18 insertions, 0 deletions
diff --git a/ui/chat/textedit.gd b/ui/chat/textedit.gd
new file mode 100644
index 0000000..ae30778
--- /dev/null
+++ b/ui/chat/textedit.gd
@@ -0,0 +1,18 @@
+extends ExpandableTextEdit
+
+signal send
+
+
+func _input(event: InputEvent) -> void:
+ if (
+ event is InputEventKey
+ and OS.get_scancode_string(event.get_scancode_with_modifiers()) in ["Kp Enter", "Enter"]
+ and event.pressed
+ ):
+ get_tree().set_input_as_handled()
+ if has_focus():
+ text = text.strip_edges()
+ if text:
+ emit_signal("send")
+ else:
+ grab_focus()