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

Set the size of the input text field #385

Closed
anshul-soni opened this issue Oct 24, 2015 · 12 comments
Closed

Set the size of the input text field #385

anshul-soni opened this issue Oct 24, 2015 · 12 comments
Labels

Comments

@anshul-soni
Copy link

Is there any way for me to set the size of the input text field ?

@ocornut
Copy link
Owner

ocornut commented Oct 24, 2015

If you mean the width, you can use PushItemWidth(xxx) for a specific size, or PushItemWidth(-xxx) to left-align. Use PopItemWidth() to return to the previous value in the stack.

@ocornut ocornut closed this as completed Oct 24, 2015
@adam4813
Copy link

It would be neat to set a character count based on m width.

@ocornut
Copy link
Owner

ocornut commented Oct 24, 2015

You can set a character count via the buffer size. Not sure why it'd be useful that InputText reduce the character count based on UI size.

Sent from my fax machine

On 2015/10/25, at 0:02, Adam Martin notifications@github.com wrote:

It would be neat to set a character count based on m width.


Reply to this email directly or view it on GitHub.

@adam4813
Copy link

adam4813 commented Oct 24, 2015 via email

@ocornut
Copy link
Owner

ocornut commented Oct 25, 2015

If you have a 3 digit ints you can pass a value of 3+1 as buffer size. I'm still not sure of what you are asking for :)

@adam4813
Copy link

adam4813 commented Oct 25, 2015 via email

@heroboy
Copy link
Contributor

heroboy commented Oct 25, 2015

ImGUI::InputInt(&x);
if (x < 0) x = 0;
else if (x > 999) x = 999;

@ocornut
Copy link
Owner

ocornut commented Oct 25, 2015

You can also replicate the behavior of InputInt() with InputText() and scanf()

@anshul-soni
Copy link
Author

Push and pop worked for me and worked better than I expected 👍

@ocornut ocornut added the layout label Apr 1, 2020
@ayazpatel
Copy link

how to give size to particular text without disturbing others

@d4rckh
Copy link

d4rckh commented Jul 2, 2022

If you mean the width, you can use PushItemWidth(xxx) for a specific size, or PushItemWidth(-xxx) to left-align. Use PopItemWidth() to return to the previous value in the stack.

what would be the equivalent for setting heights?

@PathogenDavid
Copy link
Contributor

what would be the equivalent for setting heights?

The height of text inputs is based on the font size and the frame padding. So adjust one or the other depending on the appearance you're trying to accomplish.

For font size you're best off loading the same font at various sizes and swapping between sizes using PushFont/PopFont.

For frame padding adjust it via PushStyleVar/PopStyleVar. Or if you want to affect all inputs in the entire application, via ImGuiStyle::FramePadding (although you will likely find this is affecting more things than you'd like.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants