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

How can I know if color edit popup window is closed? #6239

Closed
GasimGasimzada opened this issue Mar 12, 2023 · 3 comments
Closed

How can I know if color edit popup window is closed? #6239

GasimGasimzada opened this issue Mar 12, 2023 · 3 comments

Comments

@GasimGasimzada
Copy link

Version/Branch of Dear ImGui:

Version: docking
Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: Custom + GLFW
Compiler: MSVC and LLVM
Operating System: Windows/macOS/Linux

My Issue/Question:

I have a system in my editor that only saves values for my scene objects when the inputs are unfocused. Typically, I use ImGui::IsItemDeactivatedAfterEdit, which allows me to have live changes but not make too many file changes for the transient/active input states. This works well for normal inputs. However, color inputs also have a color picker popup that can be opened, which is something I really like but the behavior inside the popup is not desirable and not really consistent with the rest of my UI elements. When a color is picked inside the popup and the mouse click is released, Imgui sets the input as "deactivated after edit."

I am looking for a flag (e.g ImGuiColorEdit_FlagsNoDeactiveInsidePicker) or a way to determine if the picker is open and closed:

// store the value in temporary value first
ImGui::ColorEdit4("Color", myColor);

if (isColorPickerOpen()) {
  // do nothing if popup is open
} else if (IsColorPickerIsClosedAfterBeingOpen() || ImGui::IsItemDeactivatedAfterEdit()) {
  // check whether the popup is closed or the color input
  // was deactivated after typing directly to the main input
  // (not the one inside the picker)
  saveColor(myColor);
}
@ocornut
Copy link
Owner

ocornut commented Mar 13, 2023

Hello,

Given how ColorEdit4("XXXX") does PushID("XXXX"); then BeginPopup("picker");
You should be able to call IsPopupOpen(GetID("XXXXpicker") from the same location as ColorEdit4().

but the behavior inside the popup is not desirable and not really consistent with the rest of my UI elements. When a color is picked inside the popup and the mouse click is released, Imgui sets the input as "deactivated after edit."

This happen with every widget, e.g. if you click and drag a slider/drag and release you'll get the "deactivated after edit" signal. So I believe it is consistent. You can see it in "Demo->Widgets>Querying Item Status".

(Link to #2550, #1875)

@GasimGasimzada
Copy link
Author

This happen with every widget, e.g. if you click and drag a slider/drag and release you'll get the "deactivated after edit" signal. So I believe it is consistent. You can see it in "Demo->Widgets>Querying Item Status".

I meant it is consistent with Imgui behaviors but not with the behavior I am trying to achieve.

You should be able to call IsPopupOpen(GetID("XXXXpicker") from the same location as ColorEdit4().

Thank you for the tip, I'll play around with this and see how it works.

@ocornut ocornut added the popups label Mar 21, 2023
@ocornut
Copy link
Owner

ocornut commented Mar 22, 2023

Closing as answered!

@ocornut ocornut closed this as completed Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants