Skip to content

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

Closed

Description

@Cthutu

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?

Activity

  1. ocornut commented on Jun 16, 2016

    @ocornut
    Owner

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

  2. Cthutu commented on Jun 16, 2016

    @Cthutu
    Author

    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.

  3. ocornut commented on Jun 16, 2016

    @ocornut
    Owner

    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.

  4. Cthutu commented on Jun 16, 2016

    @Cthutu
    Author

    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
    .

  5. Cthutu commented on Jun 16, 2016

    @Cthutu
    Author

    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.

  6. ocornut commented on Jun 16, 2016

    @ocornut
    Owner

    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)

  7. Cthutu commented on Jun 16, 2016

    @Cthutu
    Author

    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?

  8. ocornut commented on Jun 16, 2016

    @ocornut
    Owner

    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)

  9. Cthutu commented on Jun 16, 2016

    @Cthutu
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址