mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-07 13:35:49 +02:00
Drag and Drop: Fixed submitting a tooltip from drop target location. Added demo.
Amend7bbf8f2
,92b7d6b
.
This commit is contained in:
@ -2425,6 +2425,35 @@ static void ShowDemoWindowWidgets()
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
IMGUI_DEMO_MARKER("Widgets/Drag and Drop/Tooltip at target location");
|
||||
if (ImGui::TreeNode("Tooltip at target location"))
|
||||
{
|
||||
for (int n = 0; n < 2; n++)
|
||||
{
|
||||
// Drop targets
|
||||
ImGui::Button(n ? "drop here##1" : "drop here##0");
|
||||
if (ImGui::BeginDragDropTarget())
|
||||
{
|
||||
ImGuiDragDropFlags drop_target_flags = ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoPreviewTooltip;
|
||||
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F, drop_target_flags))
|
||||
{
|
||||
ImGui::SetMouseCursor(ImGuiMouseCursor_NotAllowed);
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::Text("Cannot drop here!");
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
ImGui::EndDragDropTarget();
|
||||
}
|
||||
|
||||
// Drop source
|
||||
static ImVec4 col4 = { 1.0f, 0.0f, 0.2f, 1.0f };
|
||||
if (n == 0)
|
||||
ImGui::ColorButton("drag me", col4);
|
||||
|
||||
}
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user