mirror of
https://github.com/Relintai/Godot-TextEditor.git
synced 2025-02-04 19:15:54 +01:00
39 lines
710 B
GDScript
39 lines
710 B
GDScript
tool
|
|
extends LineEdit
|
|
|
|
onready var editor:TE_TextEditor = owner
|
|
var fr:FuncRef
|
|
|
|
func _ready():
|
|
var _e
|
|
_e = connect("text_entered", self, "_enter")
|
|
_e = connect("focus_exited", self, "_lost_focus")
|
|
|
|
add_font_override("font", editor.FONT_R)
|
|
|
|
func _unhandled_key_input(e):
|
|
if not editor.is_plugin_active():
|
|
return
|
|
|
|
if visible and e.scancode == KEY_ESCAPE and e.pressed:
|
|
fr = null
|
|
hide()
|
|
get_tree().set_input_as_handled()
|
|
|
|
func display(t:String, obj:Object, fname:String):
|
|
text = t
|
|
select_all()
|
|
fr = funcref(obj, fname)
|
|
show()
|
|
call_deferred("grab_focus")
|
|
|
|
func _lost_focus():
|
|
fr = null
|
|
hide()
|
|
|
|
func _enter(t:String):
|
|
if fr:
|
|
print("calling %s with %s" % [fr, t])
|
|
fr.call_func(t)
|
|
hide()
|