How to get "ImGui::DragInt" do work well for undo operations?


I am working on an editor. When editing a field I have two modes, Real Time (Drag), and Normal.
Using ImGui::DragInt gets me pretty close but not 100% there.

I need to know when the Drag begins, and when the Drag Ends. (When the Drag ends is when the undo state can be recorded). During the drag, the changes will be reported in real-time.

Similarly, for the Normal Mode, I need to know when the user presses the Return Key. So that I can update the real value and record the undo step.

What would be the best way to accomplish this in ImGui?




See Demo -> Widgets -> Querying Status (Active/Focused/Hovered etc.)
IsItemActivated(), IsItemDeactivatedAfterEdit() etc.

You don’t want to test the Enter key but return value of the widget and various other IsItemXXX functions.