-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Unexpected behavior of ImGui::IsItemDeactivatedXXX with multi-components widgets #2550
Comments
It's easy to understand why But then, one might expect
So yeah, quite a conflicting situation here... Looks like "Item" in both cases refers to the last component of multi-input widget? |
Also maybe these variables might help when looking at logic. When switching from first component to second:
When switching from second to first:
When switching from InputFloat2 to other widget:
|
I’ll look at this when I have time.
I am not sure why that is impossible tho? The same way you will need to handle false positives with IsItemDeactivatedAfterEdit() you should be able to trivially handle duplicate of IsItemActivated() ? |
I figured out a temporary workaround - I just store bool for each widget which checks if item was already activated or not. Feels a bit tricky and unstable, though. What behaviour in my example do you think is the most logical? |
For a start I cannot even repro the first assessment of your first post.
Doing what you suggest (e.g. start editing first value within InputFloat2, then press tab, then tab or enter to leave the second component) I get A A and never a B ( |
I believe the correct behavior for: click --> edit --> tab --> enter Should either be: Activated -> Edited --> DeactivatedAfterEdit + Activated --> Deactivated Or Activated -> Edited --> ... --> DeactivatedAfterEdit Either would work, the second one would be better. |
Agreed on second being much better. And it's strange that you don't get |
Right, so just to summarize my thoughts a little. I think the problem is two fold. The main issue is what you describe above ocurnut, that I don't get the IsItemDeactivatedAfterEdit at all. This is perhaps even more apparent if you make an InputFloat3 with three fields instead. Editing the middle value and tabbing back and forth just doesn't trigger any IsItemDeactivatedAfterEdit, even if you tab out of the group. That event does not get propagated to the group as a whole, it's just lost. (this was with v1.69, will upgrade) The other discussion revolves around what expected behavior is here. I suppose it boils down to what constitutes an undo history action. If you want to implement undo for editing each single field or only after leaving the group. I don't have a strong opinion on that but I can imagine that single field editing triggers undo in most applications with such controls? It would also be consistent with how IsItemActivated behaves now, triggering on each single field. So tabbing and editing straight through an InputFloat3 we could expect something like ABABAB. |
Issue is still there. The problem is due to how the IsItemXXX functions are written and how |
…ave no side-effect0. Demo: Add extra widget to status query test.
I have pushed a fix now. Also found and fixed another bug where (Note that they were multiple commits leading to this change, so you can't just merge the two tagged commits but you can try updating to latest master.) (Many of the code there is a little weird because it wants to be highly optimized.) |
Can confirm this works. My scenario now outputs:
|
Tested and verified, this totally solves it on my end and my undo/redo functionality now works like a charm. Great stuff. Thank you. |
Good to hear! Apologies I posted hastily yesterday and forgot to clarify which route I went for first. I went this route because it is simpler to implement (and even that took me several hours to figure out the iterate) but I will try to aim for the other version later. Receiving both activate/deactivate on same frame makes user code a little less obvious. It could be a flag of the group system to decide how to treat those events as well. |
I'm closing this as solved for now, and added myself a task to try making it possible at least of multi-component widgets to enable a mode when change of components don't trigger activated/deactivated. I'll post again if there's a change being made to this. |
Example code:
When I start editing one of the components and then switch to another (via "Tab" or by clicking), I get the following output:
Is this expected? I would expect that "Item" in
IsItemActivated
would refer to theInputFloat2
widget as a whole, not just individual text boxes.This is important for undo functionality in
InputFloat2
and similar widgets. Imagine havingInputFloat2
representing position. WhenIsItemActivated
is "true", we save position before editing. WhenIsItemDeactivatedAfterEdit
returnstrue
, we add "undo" command to undo stack. The current behaviour makes this impossible.I'll take a look at the problem myself, but would be great to hear your thoughts about this. Should the output become just:
? This would be what I'd expect from this widget. Another possibility:
(not perfect, but better than what we have now)
The text was updated successfully, but these errors were encountered: