From 49540b84390bebb2658f9ec7e7476310409f5d4a Mon Sep 17 00:00:00 2001 From: Nathan Lovato Date: Sat, 29 Jan 2022 19:40:00 -0600 Subject: [PATCH] fix: force text wrapping to update when changing font size fixes #99 --- course/common/GDScriptCodeExample.gd | 7 +++++++ ui/components/RunnableCodeExample.gd | 3 +++ 2 files changed, 10 insertions(+) diff --git a/course/common/GDScriptCodeExample.gd b/course/common/GDScriptCodeExample.gd index d999d11f..152dfda0 100644 --- a/course/common/GDScriptCodeExample.gd +++ b/course/common/GDScriptCodeExample.gd @@ -6,6 +6,7 @@ export var min_size := Vector2(600, 200) setget set_min_size func _ready() -> void: + Events.connect("font_size_scale_changed", self, "_update_size") context_menu_enabled = false shortcut_keys_enabled = false CodeEditorEnhancer.enhance(self) @@ -14,3 +15,9 @@ func _ready() -> void: func set_min_size(size: Vector2) -> void: min_size = size rect_min_size = size + + +func _update_size() -> void: + # Forces the text wrapping to update. Without this, the code can overflow + # the container when changing the font size. + rect_size = rect_size diff --git a/ui/components/RunnableCodeExample.gd b/ui/components/RunnableCodeExample.gd index a648fe1a..8ecf3fd4 100644 --- a/ui/components/RunnableCodeExample.gd +++ b/ui/components/RunnableCodeExample.gd @@ -157,3 +157,6 @@ func _update_gdscript_text_edit_width(new_font_scale: int) -> void: / _base_text_font_size ) _gdscript_text_edit.rect_min_size.y = _start_code_example_height * font_size_multiplier + # Forces the text wrapping to update. Without this, the code can overflow + # the container when changing the font size. + _gdscript_text_edit.rect_size = _gdscript_text_edit.rect_size