mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 03:58:47 +02:00
Demo: Clarified the use of IsItemHovered()/IsItemActive() right after being in the "Active, Focused, Hovered & Focused Tests" section. This will be of more importance with the introduction of tabs.
This commit is contained in:
@ -1350,6 +1350,25 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
||||
if (embed_all_inside_a_child_window)
|
||||
EndChild();
|
||||
|
||||
// Calling IsItemHovered() after begin returns the hovered status of the title bar.
|
||||
// This is useful in particular if you want to create a context menu (with BeginPopupContextItem) associated to the title bar of a window.
|
||||
static bool test_window = false;
|
||||
ImGui::Checkbox("Hovered/Active tests after Begin() for title bar testing", &test_window);
|
||||
if (test_window)
|
||||
{
|
||||
ImGui::Begin("Title bar Hovered/Active tests", &test_window);
|
||||
if (ImGui::BeginPopupContextItem()) // <-- This is using IsItemHovered()
|
||||
{
|
||||
if (ImGui::MenuItem("Close")) { test_window = false; }
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
ImGui::Text(
|
||||
"IsItemHovered() after begin = %d (== is title bar hovered)\n"
|
||||
"IsItemActive() after begin = %d (== is window being clicked/moved)\n",
|
||||
ImGui::IsItemHovered(), ImGui::IsItemActive());
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user