Drag and Drop: Fixed submitting a tooltip from drop target location. Added demo.

Amend 7bbf8f2, 92b7d6b.
This commit is contained in:
ocornut
2023-10-05 12:06:40 +02:00
parent 64b1aeebf5
commit a63e2f0a33
4 changed files with 46 additions and 4 deletions

View File

@ -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();
}