From ba55f64118841050a7be24c83b5ecfb9a7be99ae Mon Sep 17 00:00:00 2001 From: Sebastian Morr Date: Mon, 21 Sep 2020 18:59:55 +0200 Subject: [PATCH] Input line grabs focus when text editor closes --- terminal.gd | 7 +++++-- terminal.tscn | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/terminal.gd b/terminal.gd index 5cb40c6..6528692 100644 --- a/terminal.gd +++ b/terminal.gd @@ -24,8 +24,8 @@ func _ready(): for command in premade_commands: command_dropdown.get_popup().add_item(command) command_dropdown.get_popup().connect("id_pressed", self, "load_command") - command_dropdown.theme = Theme.new() - command_dropdown.theme.default_font = load("res://fonts/default.tres") + + $TextEditor.connect("hide", self, "editor_closed") #func _input(event): # if history.size() > 0: @@ -78,6 +78,9 @@ func receive_output(text): func clear(): output.text = "" +func editor_closed(): + input.grab_focus() + func check_win_condition(): if repository.shell.run("bash /tmp/win 2>/dev/null >/dev/null && echo yes || echo no") == "yes\n": main.show_win_status() diff --git a/terminal.tscn b/terminal.tscn index 6e8d43d..2c43e21 100644 --- a/terminal.tscn +++ b/terminal.tscn @@ -5,7 +5,7 @@ [ext_resource path="res://fonts/monospace.tres" type="DynamicFont" id=4] [ext_resource path="res://text_editor.tscn" type="PackedScene" id=5] -[sub_resource type="StyleBoxFlat" id=2] +[sub_resource type="StyleBoxFlat" id=1] content_margin_left = 5.0 content_margin_right = 5.0 content_margin_top = 5.0 @@ -34,7 +34,7 @@ __meta__ = { margin_right = 1920.0 margin_bottom = 1049.0 size_flags_vertical = 3 -custom_styles/normal = SubResource( 2 ) +custom_styles/normal = SubResource( 1 ) custom_fonts/normal_font = ExtResource( 4 ) scroll_following = true