-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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
InputText IsItemDeactivated() doesn't trigger after right-click on Button #6766
Comments
I had a related issue in #5904. The workaround for my specific problem won't help in this case though, same reason it won't work for #5184. My proposal towards a solution there was: Expanding on that, it should be enough to memorize at most two active items, since only one item can be activated per frame (normally, user code can activate any amount during the same frame but I would count that as a user code problem). Therefore, |
We have a similar mechanism in place (see |
I investigated this a little and I think we could get this to work by reformulating all Requires some careful/minutia work to get right, any non-obvious situation should have a test added in the Dear ImGui Test Suite but I think it can be elegantly solved. Then, the |
That was the general solution I was thinking of as well. The only problem I can think of here is that this would create an activated->activated->deactivated->deactivated order of events when clicking into another text field or using a button with PressedOnClick (where desired is A->D->A->D). This may already be solved with a 1-frame delay for IsItemActivated() inside InputText however, as it works properly when activating an InputText earlier in submission order than the currently activated InputText. |
Dear ImGui Version
This is running on Pioneer's version of ImGui 1.89.8-docking, which contains some minor patches applied for on-demand font glyph loading, a custom cursor, and hardware depth sort of ImDrawCmds.
My Issue/Question:
I'm using
ImGui::IsItemActivated()
/ImGui::IsItemDeactivated()
to implement an undo system for an editor. In brief, the undo system relies on pushing the current value when the user begins editing a field and allows ImGui to update the field to the "new value" without needing additional handling code. Individual value changes are grouped into "UndoFrames" i.e. state packets associated with a single user undo/redo operation.This works fine for most widget types, however there's an issue where
IsItemDeactivated()
does not return true when the user navigates away from anInputText
by right/middle clicking on aButton
/ButtonBehavior
which activates on right/middle mouse button. If theButtonBehavior
appears later in execution order than the InputText field,IsItemDeactivated()
will never return true even though the widget is deactivated at the end of the frame. InputText correctly signals deactivation if the user uses the left mouse button to click away however.I'm working around this in my editor code currently by rendering the offending ButtonBehavior at the start of the frame, before any user-editable inputs are submitted. I require the use of the ButtonBehavior to determine when to forward input to the viewport's input subsystem while still rendering interactable ImGui interface elements over the viewport.
I understand this to be a subset of a larger issue with
IsItemDeactivated()
and previous-frame-ID tracking, but the scope of this issue is specifically aimed atInputText
and its behavior of clearing the active ID when the user left-clicks outside of it. The issues I saw tangentially related to the problem addressed window focus issues and/or using ImGui for all viewport input handling, neither of which are relevant to this case. Additionally, I consider opening this issue report a positive impetus towards a solution for the larger issue at hand.Screenshots/Video
2023-08-30.04-42-35.mp4
Standalone, minimal, complete and verifiable example:
Click into the InputText, click away, click back, then right-click on "Break UndoSystem". You'll note that
ImGui::IsItemDeactivated()
did not return true after the last click even though the text input was deactivated.The text was updated successfully, but these errors were encountered: