pygame-text-input icon indicating copy to clipboard operation
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?

Open ycl309 opened this issue 3 years ago • 3 comments

ycl309 avatar Apr 20 '22 04:04 ycl309

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?

Nearoo avatar Apr 20 '22 13:04 Nearoo

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.

ycl310 avatar Apr 20 '22 16:04 ycl310

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.

Nearoo avatar Apr 26 '22 13:04 Nearoo