8000 input_text resets after losing focus · Issue #347 · pyimgui/pyimgui · GitHub
[go: up one dir, main page]

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

input_text resets after losing focus #347

Open
Hirikava opened this issue Sep 12, 2023 · 1 comment
Open

input_text resets after losing focus #347

Hirikava opened this issue Sep 12, 2023 · 1 comment

Comments

@Hirikava
Copy link

I tried this simple example of input_text with pyimgui + GLFW. It works fine untill text bar losing focus and value of input resets to default one.
text_val = 'Please, type the coefficient here.'
imgui.begin("Example: text input")
changed, text_val = imgui.input_text('Coefficient:', text_val)
imgui.text('You wrote:')
imgui.same_line()
imgui.text(text_val)
imgui.end()

@Aman-Anas
Copy link

Remember, this runs every frame - so when you define text_val on line 1, you're actually re-defining it every frame. You should only set text_val once, since after that it needs to hold whatever value the user inputs.

Alternatively, you can use input_text_with_hint to show a hint like that easily

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

2 participants
0