pygame-text-input
pygame-text-input copied to clipboard
Is there a way to figure out if the text field is selected? Or is the cursor active in the text field?
There is no notion of "selected", really... The textfield updates if you feed it pygame events, and it doesn't if you don't. If you want to see if the cursor is currently visible, you can check TextInputVisualizer.cursor_visible. Does that answer your question?
Is there a way to make the cursor invisible when I click on something else? So kinda like input fields on website where I click on the background, the cursor then disappears.
Yeah! You can write to the property TextInputVisualizer.cursor_visible too, which will cause the surface to rerender based on the value the next time you access it.
So e.g.
visualizer.cursor_visible = False
screen.blit(visualizer.surface, (10, 10))
will blit the surface without the cursor visible.
If you keep feeding events, it will start appearing again though.