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

Navigation using Tab Key with InputTextMultiline and ImGuiConfigFlags_NavEnableKeyboard, not detecting new line #6802

Closed
alattanzio opened this issue Sep 10, 2023 · 3 comments
Labels
bug focus inputtext nav keyboard/gamepad navigation

Comments

@alattanzio
Copy link

alattanzio commented Sep 10, 2023

Hi there,

I've found an issue which happens only with ImGuiConfigFlags_NavEnableKeyboard set.
The navigation happens with Tab Key and focus changes, but somehow the Enter button (New Line) on the InputTextMultiline is not detected, unless Enter is held down.
Is there any way to fix it ?

Example:

static bool p_open = true;
static char strFeedback[1024];
if (ImGui::Begin("Feedback", p_open, 0))
{
    ImGui::InputTextMultiline("##feedback", &strFeedback[0], IM_ARRAYSIZE(strFeedback), ImVec2(0, 120), text_flags);
    if (ImGui::Button("Send!###send"))
    {
        // send message
    }
}
ImGui::End();

Thanks, Antonio.

UPDATE:
This issue actually happens when the control InputTextMultiline is focused. Otherwise works all fine.

Focused (not working properly)
image
Not-Focused (WORKING!)
image

@ocornut ocornut added nav keyboard/gamepad navigation bug inputtext focus labels Sep 11, 2023
ocornut added a commit that referenced this issue Sep 11, 2023
…Enter key wouldn't be accepted by the widget when navigation highlight is visible. (#6802, #3092, #5759, #787)

+ Added test in ImGuiTestSuite: "widgets_inputtext_multiline_enter"
@ocornut
Copy link
Owner

ocornut commented Sep 11, 2023

Thank you for reporting.
I have pushed a fix for this 0e1ce76.
Amusingly we had a comment directly the double activation as "Harmless but bizarre." but it turned out not to be harmless.

Pushed an automated regression test to TestEngine:
ocornut/imgui_test_engine@478329f

The fact the the navigation system only emits the g.NavActivateId signal (on space or enter) when g.NavDisableHighlight == false is probably to be reworked and currently creates some inconsistency. I guess when ImGuiConfigFlags_NavEnableKeyboard is set we should always restore the highlight on tabbing.

ocornut added a commit that referenced this issue Sep 11, 2023
@ocornut
Copy link
Owner

ocornut commented Sep 11, 2023

The fact the the navigation system only emits the g.NavActivateId signal (on space or enter) when g.NavDisableHighlight == false is probably to be reworked and currently creates some inconsistency. I guess when ImGuiConfigFlags_NavEnableKeyboard is set we should always restore the highlight on tabbing.

Also pushed a change for that: b9ab6e2

@ocornut ocornut closed this as completed Sep 11, 2023
@alattanzio
Copy link
Author

That's great! Thank you so much! It was driving me crazy :) Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug focus inputtext nav keyboard/gamepad navigation
Projects
None yet
Development

No branches or pull requests

2 participants