Skip to content
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

Is there a way to figure out if the text field is selected? Or is the cursor active in the text field? #45

Open
ycl309 opened this issue Apr 20, 2022 · 3 comments

Comments

@ycl309
Copy link

ycl309 commented Apr 20, 2022

No description provided.

@Nearoo
Copy link
Owner

Nearoo commented Apr 20, 2022

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?

@ycl310
Copy link

ycl310 commented Apr 20, 2022

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.

@Nearoo
Copy link
Owner

Nearoo commented Apr 26, 2022

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.

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

No branches or pull requests

3 participants