IrvKalb / pygwidgets

A collection of user interface widgets in Python for use in programs using Pygame.
BSD 2-Clause "Simplified" License
11 stars 5 forks source link

Fix bug when running setLoc in InputText #6

Closed monteiro-renato closed 1 year ago

monteiro-renato commented 1 year ago

When running setLoc in InputText (after initialization), the fields: imageRect, rect, focusedImageRect and cursorLoc are still using the old loc. This causes a weird behaviour where you need to click the previous location to be able to edit the input field and the animations also happen in the wrong place.

Example:

image

IrvKalb commented 1 year ago

Thank you very much for not only showing this error, but for also providing a properly working solution! I wrote a test case, and your code works perfectly.

I am terrible with GitHub pull requests and merging, so I took your code and put it into my code base exactly as you wrote it. I also added the following in the comments at the top:

    TextInput - add setLoc to work correctly when moving an input field (thanks to Renato Monteiro)

I have posted the updated version so that anyone who downloads the current version will be able to use this correctly.

Thanks again!