From 3b70cc3cc9536c5631d9009b16c9a985ffdad33a Mon Sep 17 00:00:00 2001 From: Dan Lawrence Date: Thu, 7 Nov 2024 20:17:56 +0000 Subject: [PATCH] Improvements to text line fixes #627 --- .../core/drawable_shapes/drawable_shape.py | 17 +++++++++++++---- pygame_gui/elements/ui_text_entry_line.py | 1 - 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pygame_gui/core/drawable_shapes/drawable_shape.py b/pygame_gui/core/drawable_shapes/drawable_shape.py index 064ed1b0..c6413a13 100644 --- a/pygame_gui/core/drawable_shapes/drawable_shape.py +++ b/pygame_gui/core/drawable_shapes/drawable_shape.py @@ -654,7 +654,10 @@ def finalise_text(self, state_str, def apply_active_text_changes(self): """ Updates the shape surface with any changes to the text surface. Useful when we've made - small edits to the text surface + small edits to the text surface. + + This may be bugged. + """ if self.text_box_layout is not None: for state_id, state in self.states.items(): @@ -684,7 +687,10 @@ def set_text_alpha(self, alpha: int): """ self.text_box_layout.set_alpha(alpha) self.redraw_state(self.active_state.state_id, add_text=False) - self.finalise_text(self.active_state.state_id, only_text_changed=True) + self.finalise_text(self.active_state.state_id, + self.active_state.state_id + "_text", + self.active_state.state_id + '_text_shadow', + only_text_changed=False) def redraw_active_state_no_text(self): """ @@ -699,7 +705,10 @@ def finalise_text_onto_active_state(self): to lose by recreating the text from scratch. """ self.redraw_state(self.active_state.state_id, add_text=False) - self.finalise_text(self.active_state.state_id, only_text_changed=True) + self.finalise_text(self.active_state.state_id, + self.active_state.state_id + "_text", + self.active_state.state_id + '_text_shadow', + only_text_changed=False) def insert_text(self, text: str, layout_index: int, parser: Optional[HTMLParser] = None): """ @@ -722,7 +731,7 @@ def toggle_text_cursor(self): """ if self.text_box_layout is not None: self.text_box_layout.toggle_cursor() - self.apply_active_text_changes() + self.finalise_text_onto_active_state() self.active_state.has_fresh_surface = True def redraw_state(self, state_str: str, add_text: bool = True): diff --git a/pygame_gui/elements/ui_text_entry_line.py b/pygame_gui/elements/ui_text_entry_line.py index 2e25f97e..5817de84 100644 --- a/pygame_gui/elements/ui_text_entry_line.py +++ b/pygame_gui/elements/ui_text_entry_line.py @@ -356,7 +356,6 @@ def update(self, time_delta: float): if self.drawable_shape is not None: self.drawable_shape.text_box_layout.set_cursor_position(self.edit_position) self.drawable_shape.toggle_text_cursor() - self.drawable_shape.apply_active_text_changes() if self.cursor_blink_delay_after_moving_acc > self.cursor_blink_delay_after_moving: if self.blink_cursor_time_acc >= self.blink_cursor_time: