Godot-TextEditor/addons/text_editor/TE_LineEdit.gd

39 lines
710 B
GDScript3
Raw Normal View History

2021-10-11 18:41:26 +02:00
tool
2021-10-11 05:10:22 +02:00
extends LineEdit
2021-10-18 21:20:19 +02:00
onready var editor:TE_TextEditor = owner
2021-10-11 05:10:22 +02:00
var fr:FuncRef
func _ready():
var _e
_e = connect("text_entered", self, "_enter")
_e = connect("focus_exited", self, "_lost_focus")
2021-10-18 21:20:19 +02:00
add_font_override("font", editor.FONT_R)
2021-10-11 05:10:22 +02:00
func _unhandled_key_input(e):
2021-10-18 21:20:19 +02:00
if not editor.is_plugin_active():
return
if visible and e.scancode == KEY_ESCAPE and e.pressed:
2021-10-11 05:10:22 +02:00
fr = null
hide()
get_tree().set_input_as_handled()
func display(t:String, obj:Object, fname:String):
text = t
2021-10-18 21:20:19 +02:00
select_all()
2021-10-11 05:10:22 +02:00
fr = funcref(obj, fname)
show()
call_deferred("grab_focus")
func _lost_focus():
fr = null
hide()
func _enter(t:String):
2021-10-18 21:20:19 +02:00
if fr:
print("calling %s with %s" % [fr, t])
fr.call_func(t)
2021-10-11 05:10:22 +02:00
hide()