mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 12:08:47 +02:00
Added IsItemDeactivatedAfterChange() if the last item was active previously, isn't anymore, and during its active state modified a value. Note that you may still get false positive. (#820, #956, #1875)
This commit is contained in:
@ -1178,18 +1178,21 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
||||
// Display the value of IsItemHovered() and other common item state functions. Note that the flags can be combined.
|
||||
// (because BulletText is an item itself and that would affect the output of IsItemHovered() we pass all state in a single call to simplify the code).
|
||||
static int item_type = 1;
|
||||
static bool b = false;
|
||||
static float col4f[4] = { 1.0f, 0.5, 0.0f, 1.0f };
|
||||
ImGui::RadioButton("Text", &item_type, 0); ImGui::SameLine();
|
||||
ImGui::RadioButton("Button", &item_type, 1); ImGui::SameLine();
|
||||
ImGui::RadioButton("SliderFloat", &item_type, 2); ImGui::SameLine();
|
||||
ImGui::RadioButton("ColorEdit4", &item_type, 3); ImGui::SameLine();
|
||||
ImGui::RadioButton("ListBox", &item_type, 4);
|
||||
ImGui::RadioButton("CheckBox", &item_type, 2); ImGui::SameLine();
|
||||
ImGui::RadioButton("SliderFloat", &item_type, 3); ImGui::SameLine();
|
||||
ImGui::RadioButton("ColorEdit4", &item_type, 4); ImGui::SameLine();
|
||||
ImGui::RadioButton("ListBox", &item_type, 5);
|
||||
bool ret = false;
|
||||
if (item_type == 0) { ImGui::Text("ITEM: Text"); } // Testing text items with no identifier/interaction
|
||||
if (item_type == 1) { ret = ImGui::Button("ITEM: Button"); } // Testing button
|
||||
if (item_type == 2) { ret = ImGui::SliderFloat("ITEM: SliderFloat", &col4f[0], 0.0f, 1.0f); } // Testing basic item
|
||||
if (item_type == 3) { ret = ImGui::ColorEdit4("ITEM: ColorEdit4", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged)
|
||||
if (item_type == 4) { const char* items[] = { "Apple", "Banana", "Cherry" }; static int current = 1; ret = ImGui::ListBox("ITEM: ListBox", ¤t, items, IM_ARRAYSIZE(items), IM_ARRAYSIZE(items)); }
|
||||
if (item_type == 2) { ret = ImGui::Checkbox("ITEM: CheckBox", &b); } // Testing checkbox
|
||||
if (item_type == 3) { ret = ImGui::SliderFloat("ITEM: SliderFloat", &col4f[0], 0.0f, 1.0f); } // Testing basic item
|
||||
if (item_type == 4) { ret = ImGui::ColorEdit4("ITEM: ColorEdit4", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged)
|
||||
if (item_type == 5) { const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::ListBox("ITEM: ListBox", ¤t, items, IM_ARRAYSIZE(items), IM_ARRAYSIZE(items)); }
|
||||
ImGui::BulletText(
|
||||
"Return value = %d\n"
|
||||
"IsItemFocused() = %d\n"
|
||||
@ -1200,6 +1203,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
||||
"IsItemHovered(_RectOnly) = %d\n"
|
||||
"IsItemActive() = %d\n"
|
||||
"IsItemDeactivated() = %d\n"
|
||||
"IsItemDeactivatedAfterChange() = %d\n"
|
||||
"IsItemVisible() = %d\n",
|
||||
ret,
|
||||
ImGui::IsItemFocused(),
|
||||
@ -1210,6 +1214,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
||||
ImGui::IsItemHovered(ImGuiHoveredFlags_RectOnly),
|
||||
ImGui::IsItemActive(),
|
||||
ImGui::IsItemDeactivated(),
|
||||
ImGui::IsItemDeactivatedAfterChange(),
|
||||
ImGui::IsItemVisible()
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user