You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to disable shortcuts when a modal popup is active.
These new shortcuts are great, and I have a full window ImGui application where I would like to use them. Think of main menu actions such as "Open new tab" or "Save all" in a text editor.
Since I have a few non-modal windows popping around I'm flagging the shortcuts with ImGuiInputFlags_RouteGlobal so that the main window gets the notification even when it does not have the focus.
The only issue is that they are activated even when a modal pop-up window is shown, such a confirmation question:
User presses Ctrl+Q.
The main window receives the "quit" shortcut, correctly.
Modal question "Are you sure you want to quit without saving?".
User presses any other shortcut. It is activated, but it should not because there is a modal popup blocking the UI.
Currently I'm using IsPopupOpen(NULL, ImGuiPopupFlags_AnyPopup) to disable the shortcuts, which is not ideal because it disables them too for non-modal pop-ups, which it should not (it interacts badly with ImGuiInputFlags_Tooltip).
I think it should be nice to have a flag ImGuiInputFlags_RouteUnlessModal for that.
Naturally, having a ImGuiPopupFlags_AnyModal for the IsPopupOpen() would be useful, too.
Or am I missing an obvious way to do what I want with the current version?
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
No response
The text was updated successfully, but these errors were encountered:
Currently I'm using IsPopupOpen(NULL, ImGuiPopupFlags_AnyPopup) to disable the shortcuts, which is not ideal because it disables them too for non-modal pop-ups,
In the meanwhile you can use FindBlockingModal(NULL) != NULL as better workaround.
Aside from technical issues suggested in #7646 i believe this may need some careful design:
I don't necessarily think that blocking shortcuts below a modal is always specific to a modal: could be desirable for popup?
Heck I am not even 100% sure it is always desirable that a modal blocks shortcuts, even if I agree it's likely desirable most of the times.
I don't know yet if the right design would be to alter routing options at the polling site (as you suggested), or if we also need flags for popup themselves to select how we block things, or we need a combination of both.
Note that modals may be stacked. Some users use long-lived modals (e.g. full featured editors/tools) where of course Shortcuts() declared in that modal need to work within the modal, but probably not if a nested modal appears.
Handing this is therefore going to alter the perception of ImGuiInputFlags_RouteGlobal, just as the default ImGuiInputFlags_RouteFocused, the calling location matters.
Intuitively I would imagine that we would swap your proposal of ImGuiInputFlags_RouteUnlessModal to ImGuiInputFlags_RouteOverModals.
Version/Branch of Dear ImGui:
Version 1.90.7
Back-ends:
n/a
Compiler, OS:
all
Full config/build information:
No response
Details:
I need to disable shortcuts when a modal popup is active.
These new shortcuts are great, and I have a full window ImGui application where I would like to use them. Think of main menu actions such as "Open new tab" or "Save all" in a text editor.
Since I have a few non-modal windows popping around I'm flagging the shortcuts with
ImGuiInputFlags_RouteGlobal
so that the main window gets the notification even when it does not have the focus.The only issue is that they are activated even when a modal pop-up window is shown, such a confirmation question:
Currently I'm using
IsPopupOpen(NULL, ImGuiPopupFlags_AnyPopup)
to disable the shortcuts, which is not ideal because it disables them too for non-modal pop-ups, which it should not (it interacts badly withImGuiInputFlags_Tooltip
).I think it should be nice to have a flag
ImGuiInputFlags_RouteUnlessModal
for that.Naturally, having a
ImGuiPopupFlags_AnyModal
for theIsPopupOpen()
would be useful, too.Or am I missing an obvious way to do what I want with the current version?
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
No response
The text was updated successfully, but these errors were encountered: