ColorEdit with EnterReturnsTrue / MouseReleaseReturnsTrue


#1

Hello,

I really like the color picker that is in ImGui, but I would only like to apply the color changes conservatively. For e.g. InputText I do the same by using ImGuiInputTextFlags_EnterReturnsTrue. This however does not seem to be exposed for the color edit. Is there a clean way I can add this without modifying ImGui or are you planning to add this in the short term? Is there a clean way to also only apply the color when the mouse is released instead of while dragging, or maybe even better when the color picker popup is closed? (I open the color picker through the ColorButton).

I’m pretty sure I could do all above myself, but it would require me to either change ImGui source, or duplicate large parts of ImGui::ColorPicker(…).

Thanks in advance for your time to answer.


#2

You could just pass a temporary variable with ColorEdit and copy it when released?
e.g. call ImGui::IsItemDeactivatedAfterEdit() and copy the variable back to your origin when done, or something like that?


#3

Thanks Omar for the fast response. I wasn’t aware that function existed. That helped me a lot and opened my eyes to more ways to query the state of items.

In the end I managed to make it work with that function and some custom functions specifically made to determine the color box (in the popup) press and release moments to determine when to copy into the temporary.