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

Accepting input on text field losing 'focus'. #700

Closed
Cthutu opened this issue Jun 16, 2016 · 9 comments
Closed

Accepting input on text field losing 'focus'. #700

Cthutu opened this issue Jun 16, 2016 · 9 comments

Comments

@Cthutu
Copy link

Cthutu commented Jun 16, 2016

I'm trying to solve a problem with input text fields. Currently they only return true when enter is pressed (due to ImGuiInputTextFlags_EnterReturnsTrue flag), but I also want it to return true when TAB is pressed to go to next input field, or if the mouse is clicked elsewhere.

A good example of where this is useful is in InputInt3 where pressing TAB is quite natural for people to accept an entry for the first int and move to the next int.

Any advice or is it just not possible with the current implementations?

@ocornut
Copy link
Owner

ocornut commented Jun 16, 2016

Hi,
Isn't just the default behavior aka returning true whenever changed, enough?

@Cthutu
Copy link
Author

Cthutu commented Jun 16, 2016

It doesn't behave the same way as Windows or Mac. When tabbing to the next field or click outside the input field, the user doesn't expect their previous input to be reset. The only time it is reset in these OS's is by pressing ESC.

For example, open notepad and go to the 'Save As...' dialog box. Enter a filename and press TAB. The filename you enter doesn't disappear.

It's not a showstopper, but I do try to aim for the Principle of Least Surprise when it comes to UIs.

@ocornut
Copy link
Owner

ocornut commented Jun 16, 2016

Err, the value should never be reset in ImGui unless you press Esc. If that this the case then it is a bug and that should be fixed instead of adding a new flag.

On 16 Jun 2016, at 21:36, Cthutu notifications@github.com wrote:

It doesn't behave the same way as Windows or Mac. When tabbing to the next field or click outside the input field, the user doesn't expect their previous input to be reset. The only time it is reset in these OS's is by pressing ESC.

For example, open notepad and go to the 'Save As...' dialog box. Enter a filename and press TAB. The filename you enter doesn't disappear.

It's not a showstopper, but I do try to aim for the Principle of Least Surprise when it comes to UIs.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

@Cthutu
Copy link
Author

Cthutu commented Jun 16, 2016

Interesting: in the demo, input float3 works when tab is pressed. Let me
look at this more closely.

On Thu, 16 Jun 2016 at 15:50 omar notifications@github.com wrote:

Err, the value should never be reset in ImGui unless you press Esc. If
that this the case then it is a bug and that should be fixed instead of
adding a new flag.

On 16 Jun 2016, at 21:36, Cthutu notifications@github.com wrote:

It doesn't behave the same way as Windows or Mac. When tabbing to the
next field or click outside the input field, the user doesn't expect their
previous input to be reset. The only time it is reset in these OS's is by
pressing ESC.

For example, open notepad and go to the 'Save As...' dialog box. Enter a
filename and press TAB. The filename you enter doesn't disappear.

It's not a showstopper, but I do try to aim for the Principle of Least
Surprise when it comes to UIs.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#700 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AAVRxgd5kiFWVo5Vp6b8_L108PIMEdBVks5qMakKgaJpZM4I3tLb
.

@Cthutu
Copy link
Author

Cthutu commented Jun 16, 2016

OK, the demo doesn't use the EnterReturnsTrue flag, which is why it works. For example, I change the code in the demo to be:

if (ImGui::InputFloat3("input float3", vec4a, -1, ImGuiInputTextFlags_EnterReturnsTrue))
{
    ImGui::LogText("Changed");
}

When you press TAB now, it resets. Without the flag I get it returning true everytime I type a key which is not what I want. I am forced to use the EnterReturnsTrue flag.

@ocornut
Copy link
Owner

ocornut commented Jun 16, 2016

Isn't that the point of that flag? What problem are you trying to solve?
ImGuiInputTextFlags_EnterReturnsTrue = 1 << 5, // Return 'true' when Enter is pressed (as opposed to when the value was modified)

@Cthutu
Copy link
Author

Cthutu commented Jun 16, 2016

That flag is the only way to return true once when the input is done with. Currently knowing when the input is done with is when you press 'enter', which is all well and good. However, on modern operating systems, they decide when you've finish editing by 'enter', 'tab' or clicking elsewhere. So, I am guess I am saying I really want this flag:

ImGuiInputTextFlags_EnterTabClickElsewhereReturnsTrue

:)

Of course, a ImGuiInputTextFlags_InputDoneReturnsTrue would be more sensible a name!

Is it clear what I am getting at?

@ocornut
Copy link
Owner

ocornut commented Jun 16, 2016

Granted, then we'd need a new flag and to rework InputText accordingly.
Though I am wondering if you are having issue with immediate update and what sort of issues? (I myself sometimes wanted non-immediate update)

@Cthutu
Copy link
Author

Cthutu commented Jun 16, 2016

Setting the xyz values of an object is something you don't live update on,
otherwise the object will be jumping about as you type :)
On Thu, Jun 16, 2016 at 16:14, omar notifications@github.com wrote:

Closed #700 #700.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#700 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AAVRxuaW4yAiC-FEEvgVtbuotaN9AWAdks5qMa6ygaJpZM4I3tLb
.

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

No branches or pull requests

2 participants