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

InputText.flags(InputTextFlags::ENTER_RETURNS_TRUE) limits input to max of 7 #757

Closed
jestarray opened this issue Dec 29, 2023 · 1 comment

Comments

@jestarray
Copy link

jestarray commented Dec 29, 2023

// THIS LIMITS TEXT INPUT TO 7 MAX!
ui.input_text("##", &mut buff).flags(InputTextFlags::ENTER_RETURNS_TRUE).build();

// this does not!
ui.input_text("##", &mut buff).enter_returns_true(true).build();

Please describe your environment

  • imgui-rs version [0.11.0]
  • Windows 10(sdl2), Arch Linux(glfw)

The video demonstrates this. I am mashing my keyboard but first example does not go past 7 chars.

2023-12-28_22-34-46.mp4
dbr added a commit that referenced this issue May 5, 2024
To clarify potentially confusion like #757
@dbr
Copy link
Contributor

dbr commented May 5, 2024

Ah - this seemed very mysterious at first, but it is acting correctly:

By default, the input_text widget has InputTextFlags::CALLBACK_RESIZE set - this enables imgui-rs to automatically resize the buffer as needed. It's set here

If you set flags like that - it replaces any existing flags with only ENTER_RETURNS_TRUE - disabling the auto-resizing of the text buffer

The important difference being fn flags(...) sets self.flags = ... whereas fn enter_returns_true calls flags.set(...)

So you could either do

ui.input_text("##", &mut buff).flags(InputTextFlags::ENTER_RETURNS_TRUE | InputTextFlags::CALLBACK_RESIZE).build();

or use the enter_returns_true

I've added a docstring to the flags method to note this, as it's easy to overlook!

@dbr dbr closed this as completed May 5, 2024
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