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

Maintain InputText selection state/active widget after menu usage #622

Open
pdoane opened this issue Apr 29, 2016 · 2 comments
Open

Maintain InputText selection state/active widget after menu usage #622

pdoane opened this issue Apr 29, 2016 · 2 comments
Labels
focus inputtext nav keyboard/gamepad navigation

Comments

@pdoane
Copy link

pdoane commented Apr 29, 2016

If I click on a menu bar while a text input widget is active with a selection, that selection is lost after interaction with the menu bar is complete. It also looks like the text input widget is no longer active.

I would expect that interacting with either the window's menu bar or the global menu bar to not modify the active widget or its state.

@ocornut
Copy link
Owner

ocornut commented Apr 29, 2016

That's correct. That sort of focusing behavior isn't supported at all yet. It would be a rather non-trivial feature to extend ImGui toward that - compared to IHMO the benefits. But doable. I am adding a note to myself that the enhancement is desirable but it would be rather low in the priority list at the moment.

@ocornut
Copy link
Owner

ocornut commented May 3, 2016

Quick ideas and thinking aloud.

At the time of stealing focus from a window we could store e.g. a LastActiveId within ImGuiWindow, which could then be restored upon restoring focus when popping from OpenPopupStack. Pretty much that (plus/minus dozen of edge cases).

The problem is that we only store 1 instance of state for InputText(), so restoring focus on a text input after another has been used would lose cursor position, undo stack, etc. It may or not be a problem for you.

The majority of that stored space are the undo buffers (currently hardcoded to be ~3K). We could probably devise a general scheme for storing cursor/selection for all visible InputText(), not as much a problem of storage space there but design (when to store/restore).

Undo buffer is a little more tricky. Keeping undo data when the InputText() isn't active (when it "owns" the text) opens issues and may not play well with end-user code who may have larger-scale undo in place. (It is currently already a problem if you use text input, un-select, mess up with data outside of imgui, select text input again and use redo/undo. I could compare hash of text between last unselect and current time see if undo-buffers are still valid).

We could add options to InputText() to e.g. disable undo-buffer; request persistent undo-buffer for this instance; request semi-persistent undo-buffer for this instance, ditched when id disappear, etc.

So at the end of the day most of the work for this feature wouldn't be maintenance of ActiveId state but rather work on InputText() - unless you don't care about the text selection.

May work on #323 at some point and this would probably requires maintain a stack of focused/selected items when popups are used.

@ocornut ocornut added the focus label Sep 25, 2017
@ocornut ocornut added nav keyboard/gamepad navigation inputtext labels Jan 31, 2018
@ocornut ocornut changed the title Maintain selection state/active widget after menu usage Maintain InputText selection state/active widget after menu usage Jan 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus inputtext nav keyboard/gamepad navigation
Projects
None yet
Development

No branches or pull requests

2 participants