Skip to content

Conversation

@FoamyGuy
Copy link
Contributor

Another fix for TextBox

This fixes an issue when TextBox is initialized with empty Text the self._bitmap can be None when it tries to fill it with background color. By ensuring that kwargs["text"] is set to a space instead of empty string before the call to super init it ensures that the Bitmap will always get created.

@FoamyGuy FoamyGuy marked this pull request as draft December 12, 2025 22:40
@FoamyGuy FoamyGuy marked this pull request as ready for review December 12, 2025 23:19
@FoamyGuy
Copy link
Contributor Author

The latest commits avoid the text property of the TextBox containing a space after it was initialized as empty. In most cases this would not matter, but in my use case I am doing input_box.text += keyboard_keys so the extra space gets preserved during concatenation with incoming new text.

Also used _full_text internally within TextBox in a few more places which is more correct now after the refactoring, though in this case doesn't cause any difference in behavior.

Copy link
Contributor

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems ok, but could self._bitmap always be created even if the text is empty? Then there is no hack needed.

@FoamyGuy
Copy link
Contributor Author

I will merge this for now to resolve the exception.

I can also look into always creating the bitmap without resorting to spoofing the text value. I think I tried that way first and it caused some of the bounding box calculations from where the bitmap is created to turn out differently and made the box shift upwards some.
I'll try to get it working that way and make a follow up PR that swaps out the workaround for a better approach.

@FoamyGuy FoamyGuy merged commit 229b3f4 into adafruit:main Dec 13, 2025
1 check passed
adafruit-adabot pushed a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Dec 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants