Skip to content

Commit

Permalink
fix: force text wrapping to update when changing font size
Browse files Browse the repository at this point in the history
fixes #99
  • Loading branch information
NathanLovato committed Jan 30, 2022
1 parent 1090f14 commit 49540b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions course/common/GDScriptCodeExample.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
3 changes: 3 additions & 0 deletions ui/components/RunnableCodeExample.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 49540b8

Please sign in to comment.