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

Widgets returning true only when they change value? #956

Closed
ongamex opened this issue Dec 29, 2016 · 9 comments
Closed

Widgets returning true only when they change value? #956

ongamex opened this issue Dec 29, 2016 · 9 comments

Comments

@ongamex
Copy link

ongamex commented Dec 29, 2016

I'm trying to implement a simple Undo/Redo for my level editor.
I use ImGui::DragFloat (and others..) to manipulate the values that I need to have history.
These values are updated when ImGui::DragFloat (and others) returns true.

The problem that I have is that ImGui::DragFloat returns true even when 'sliding' the widget, I want to get notified somehow when to user stopped interacting with the ImGui::DragFloat (for example edited with the keyboard and hit enter, or the user released the mouse) in order to create an undoable state only then.

is there a way to achieve this?

@ocornut
Copy link
Owner

ocornut commented Dec 29, 2016 via email

@ongamex
Copy link
Author

ongamex commented Dec 29, 2016

Thanks for the quick replay,

For the hack, it's a pity that it does not work with PushID and thus with DragFloat2/3/4.

@ocornut
Copy link
Owner

ocornut commented Dec 29, 2016 via email

@ongamex
Copy link
Author

ongamex commented Dec 30, 2016

Yeah, the way I solved my problem is using the "hack" from #820 and basically duplicating the code for DragFloatN and tweaking it a little bit.

Here is the code just in case someone else needs it:
https://gist.github.com/ongamex/155c8b64186a4f5f41353dbfccbb018e

@ocornut ocornut changed the title [Question] Widgets when they change value Widgets returning true only when they change value? Jan 2, 2017
@ocornut
Copy link
Owner

ocornut commented Jan 2, 2017

So the problem is that the proposed solution for IsItemActiveLastFrame doesn't work for groups because the way EndGroup() makes IsItemActive() works is a little dodgy in the first place.
So we can aim at providing an official IsItemActiveLastFrame (even as an internal) function that works for groups (I don't know how to implement it yet but will find a solution) and expose IsItemJustReleased() publicly.

@eliasdaler
Copy link
Contributor

Is there any progress in this? I think that it's a pretty important feature to have, seeing how many GUIs use this behavior as "PropertyChanged" event.

@ocornut
Copy link
Owner

ocornut commented May 22, 2017

It's not as easy as it sounds because of the architecture of InputText, which needs to be cleaned up. No progress on it yet.

@eliasdaler
Copy link
Contributor

Okay, maybe anything I could help with? Or maybe changes are going to be pretty radical?

ocornut added a commit that referenced this issue Jun 12, 2018
…usly but isn't anymore. Useful for Undo/Redo patterns. (#820, #956, #1875)
ocornut added a commit that referenced this issue Jun 12, 2018
…iously, isn't anymore, and during its active state modified a value. Note that you may still get false positive. (#820, #956, #1875)
@ocornut
Copy link
Owner

ocornut commented Jun 12, 2018

@ongamex @eliasdaler
We now have a better solution for this issue that handle groups and multi-elements widget.
See there:
#1875 (comment)
(Closing this topic, please report/discuss in #1875 onward! Thanks!)

@ocornut ocornut closed this as completed Jun 12, 2018
ocornut added a commit that referenced this issue Aug 16, 2018
…n a group, affecting ColorPicker (broken in 1.62). Made ActiveIdIsAlive track the actual ID to avoid incorrect polling in BeginGroup/EndGroup when the ID changes within the group. (#2023, #820, #956, #1875).
ocornut added a commit that referenced this issue Aug 23, 2018
…) for consistency with new IsItemEdited() API. Kept redirection function (will obsolete fast as IsItemDeactivatedAfterChange() is very recent). (#820, #956, #1875, #2034)
ocornut added a commit that referenced this issue Feb 6, 2019
…emDeactivatedAfterEdit functions which are useful to implement variety of undo patterns. (#820, #956, #1875)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants