online multiplayer chess game (note server currently down)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
extends CanvasLayer
class_name VirtualKeyboard

onready var holder = $ForceDown
var text: TextEditor

signal done(text)
signal closed(text)

export(PackedScene) var text_editor


func _ready():
	if !OS.has_touchscreen_ui_hint():
		$ForceDown/Panel/V/KeyHolder.free()  # remove keys if not touchscreen
	text = text_editor.instance()
	$ForceDown/Panel/V.add_child(text)
	$ForceDown/Panel/V.move_child(text, 0)
	text.connect("done", self, "done")


func open(with_text: String = "") -> void:
	text.text = with_text
	var txedit = text.textedit
	txedit.grab_focus()
	txedit.cursor_set_line(txedit.get_line_count() - 1)
	txedit.cursor_set_column(len(txedit.get_line(txedit.get_line_count() - 1)))

	show()


func hide():
	holder.hide()


func show():
	holder.show()


func done(tx := text.text) -> void:
	emit_signal("done", tx)
	hide()


func _on_Close_pressed():
	hide()
	emit_signal("closed", text.text)