Skip to content

Commit

Permalink
Merge pull request #654 from MyreMylar/fix-text-entry-line
Browse files Browse the repository at this point in the history
Improvements to text line
  • Loading branch information
MyreMylar authored Nov 7, 2024
2 parents 92cd0bc + 3b70cc3 commit 8235cd8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
17 changes: 13 additions & 4 deletions pygame_gui/core/drawable_shapes/drawable_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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):
"""
Expand All @@ -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):
"""
Expand All @@ -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):
Expand Down
1 change: 0 additions & 1 deletion pygame_gui/elements/ui_text_entry_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 8235cd8

Please sign in to comment.