-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UITextEntryBox desyncs in an edge case #606
Comments
I can confirm I can reproduce this, but it seems to happen only sporadically. Might take me a while to pin down why this is happening. |
Ah, it's a pity it's reproducible ^^ I'd love to help out if I can get some pointers on where to poke around! |
The following code reproducibly produces the buggy behaviour with just a newline as initial text: import pygame
import pygame_gui
pygame.init()
screen = pygame.display.set_mode((400, 200))
clock = pygame.time.Clock()
manager = pygame_gui.UIManager((400, 200))
text_entry_box = pygame_gui.elements.UITextEntryBox(
initial_text="\n",
relative_rect=pygame.Rect(0, 0, 400, 200),
)
text_entry_box.focus()
# simulating keypress
manager.process_events(pygame.Event(pygame.KEYDOWN, {'key': pygame.K_RETURN, 'mod': 0}))
manager.process_events(pygame.Event(pygame.TEXTINPUT, {'text': "a"}))
is_running = True
while is_running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
is_running = False
manager.process_events(event)
dt = clock.tick(60) / 1000
manager.update(dt)
manager.draw_ui(screen)
pygame.display.update() I have noticed the buggy behaviour seems to happen when inserting more than one blank line and jumping back to insert something to one of the blank lines in the middle. Working on a fix right now but I don't have it fully worked out yet. I found out that |
Describe the bug
Stumbled upon this while getting to know this lovely library (thank you for that!).
The behavior I observed was that sometimes when entering a newline and a character directly after it, the character would propagate to the widget's internal state, but not the widget. In the widget, selection is moved down a line instead.
To Reproduce
I've construct a small example of this behavior:
Steps to reproduce the behaviour:
while True:
)j
Expected behaviour
I expect the typed character to be visible in the widget, so there is no desync between state and widget state.
Platform and software (please complete the following information):
OS: Linux, Ubuntu 22.04.4 LTS
pip freeze
:The text was updated successfully, but these errors were encountered: