-
Notifications
You must be signed in to change notification settings - Fork 588
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
How to get TAB to navigate between edit widgets? #59
Comments
OK, so just to say I do have a way to do it, but it seems like much more work than makes sense. Check for KEY_TAB pressed in the render loop, and increment a counter; if the edit being created matches the counter, set the edit focus. Some other mechanism would be much more friendly. |
Thanks for asking and glad you already found the "recommended" solution.
I'm not sure we would want something like that. There would need to be a transparent way how to determine which widget has widget in the current frame and which widget will get it after receiving Shift+Tab (backward) or just Tab (forward). Such thing is not easy and we would probably end up with just saying "the last rendered" widget for Shift+Tab and "the next to be rendered widget" for Tab. But that's still far from being transparent/unambiguous - imagine all the if-else logic for widget creation. Furthermore there are popups and stuff (messing with the logical "previous widget" and "next widget" transparency). This would get messy very early. So I think the solution with an explicit variable (e.g. counter) is the best to my knowledge 😉. Thoughts? |
The real difficulty is that because of immediate-mode, you don't really have knowledge of all the widgets which might exist during a frame, as you would with traditional GUIs. That said, if there were a 'tabbing order' field, say, in each widget, where the programmer assigned that order (or it could alternatively be auto-assigned in widget-creation order), then it would be possible to handle Tab/Shift+Tab inside Nuklear and just give the focus to the next widget in the assigned order. Possible? |
That's what I described above as a problematic approach. But how would you handle (in a more readable and easier way than your current solution) all the cases where the programmer wouldn't want neither the default ordering and maybe not even the at-compile-time-known ordering (because that changes in accordance to which widgets will get drawn and which not in that particular frame based on user input or other criteria)? Just a smallest example. Nuklear draws stuff mostly (not always due to layouting, compound widgets, popups, etc.) top-down left-right, but that's not how a human perceives the wished "tab order". This "jumpy" experience would get even worse e.g. for arabic people who read buttom-top right-left. I think this lurks on the edge of this small library - either we would need to introduce full locale support (which is itself bigger than the current |
Actually, I think allowing a 'userdata' pointer for all widgets would be a great thing. As far as tab ordering, I am assuming that only widgets with a tab-order would get tabbed-to. So part of the widget's construction (or a helper like 'widget_tab_order' or something) would set how to handle tabs for that item. I guess it works out to be more complex for Nuklear, and could be handled (by me, anyway) if a userdata pointer were available. |
Ok, that doesn't sound bad to me - PRs welcome 😉. |
Hey man, I've got two PRs in the queue already... |
Which is perfect - I'm glad there is the code. We're just out of manpower to review that everything. The thing is immediate mode UIs are really complicated architecturally and all the subtleties are not easy to review 😢. That's why I'm so persistent about thorough reviews - an ideal case would be to require at least 2 different persons to review each PR in our case, but if there is bunch of people having a different idea (and consensus among them) how to evolve Nuklear, I'm all for it 😉. |
I feel your pain :) I've got several beta-testers giving me valuable feedback as I port 8th from JUCE to Nuklear. It's a ton of work rewriting all the docs, and filling in the missing bits. |
i think this might be simpler than we thought. i can navigate through the edit fields in properties using tab: recording.mp4and it even circles around to the first element, by using these macros:
(i think and then calling i suppose at that level of complexity it wouldn't be hard to integrate into nuklear proper and make it work for both edit fields and properties.. |
I've got a layout with labels on the left and edit controls on the right. Everything works nicely, but I want to be able to hit TAB (for instance) to move from one 'field' to the next.
What is the proper way to accomplish this?
The text was updated successfully, but these errors were encountered: