mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-14 00:34:18 +00:00
Added context menu example on a DragFloat widget
This commit is contained in:
parent
487500d291
commit
90db64d4e3
1 changed files with 15 additions and 2 deletions
17
imgui.cpp
17
imgui.cpp
|
|
@ -10609,12 +10609,25 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||
}
|
||||
|
||||
if (ImGui::Button("Popup Menu.."))
|
||||
ImGui::OpenPopup("context menu");
|
||||
if (ImGui::BeginPopup("context menu"))
|
||||
ImGui::OpenPopup("popup from button");
|
||||
if (ImGui::BeginPopup("popup from button"))
|
||||
{
|
||||
ShowExampleMenuFile();
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
static float value = 0.5f;
|
||||
ImGui::PushItemWidth(100); ImGui::DragFloat("Context Menu", &value); ImGui::PopItemWidth();
|
||||
if (ImGui::IsItemHovered() && ImGui::IsMouseClicked(1))
|
||||
ImGui::OpenPopup("context menu");
|
||||
ImGui::SameLine(); ImGui::Text("<-- right-click");
|
||||
if (ImGui::BeginPopup("context menu"))
|
||||
{
|
||||
if (ImGui::Selectable("Set to zero")) value = 0.0f;
|
||||
if (ImGui::Selectable("Set to PI")) value = PI;
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue