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

Recommendation for a scrollable list of InputText() fields ? #1871

Closed
ghost opened this issue Jun 8, 2018 · 3 comments
Closed

Recommendation for a scrollable list of InputText() fields ? #1871

ghost opened this issue Jun 8, 2018 · 3 comments

Comments

@ghost
Copy link

ghost commented Jun 8, 2018

[edit: Found BeginChild()/EndChild() ]

Originally I was going to post about a problem I was having about InputText() not scrolling correctly in to view within my Listbox() when I realise that's not probably how it should have even been constructed ( the software has two modes, standard, and "editing", and in standard I'm using Selectable(), but when in editing I change to InputText(), so that's how the mistake happened ).

As such, I'm curious, what would be a preferred technique for having a scrollable list of InputText() entries ( in picture, the right hand column, with blue highlighted $$$178 field, all these are InputText()).

s

@ghost
Copy link
Author

ghost commented Jun 9, 2018

I found BeginChild()/EndChild(), all good.

Leaving here for possible future reference.

...though I still can't seem to get the ImGui::SetKeyboardFocusHere() to seem to work properly if the item desired is not visibly present in the child window area. The right item is having the SetKeyboardFocusHere() set before it, but instead the focus goes to the top of the currently visible window. Not yet sure where the flaw is in my own code.

@ghost ghost closed this as completed Jun 9, 2018
@ocornut
Copy link
Owner

ocornut commented Jun 9, 2018

...though I still can't seem to get the ImGui::SetKeyboardFocusHere() to seem to work properly if the item desired is not visibly present

Yes there is currently an issue because the action for SetKeyboardFocusHere() is only processed on non-clipped items. This relate to #1074, #432, #343.

Some possible temporary workaround:

  • You can first scroll to the item by using SetScrollFromPosY().
  • You may it work it out using imgui_internal.h and the SetFocusID() function, for which you'll need an ID (which can be retrieved with GetID(label) in the same scope) and a window GetCurrentWindow() also from imgui_internal.h)

Note of those are very pleasant work-around but they should help in the meanwhile. I will be working on new functions to solve this properly later.

@ghost
Copy link
Author

ghost commented Jun 9, 2018

Thanks @ocornut . I did end up working my way around it using your first suggestion about an hour ago (scroll first, then set the keyboard focus). It's working well enough now for me to get on with the task at hand since it's just an internal build for me. Looking forward to seeing how you end up resolving it, best of luck, and thanks for taking the time to reply.

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

No branches or pull requests

1 participant