Imgui: Set the size of the input text field

Created on 24 Oct 2015  Â·  9Comments  Â·  Source: ocornut/imgui

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

layout

Most helpful comment

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.

All 9 comments

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.

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

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 [email protected] wrote:

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

―
Reply to this email directly or view it on GitHub.

I meant for fixed size numbers like 3 digit ints.

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 :)

InputInt4 doesn't take a character buffer it takes an int storage. So for
similar methods having a fixed width would be neat, but yoi can do it
otherwise as you describe and not be lazy like I'm describing ;).

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

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

Push and pop worked for me and worked better than I expected :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dowit picture dowit  Â·  3Comments

ocornut picture ocornut  Â·  3Comments

Folling picture Folling  Â·  3Comments

noche-x picture noche-x  Â·  3Comments

bogdaNNNN1 picture bogdaNNNN1  Â·  3Comments