Closed dgregorius closed 2 months ago
I just randomly stumbled on this message while browsing old ones...
You mention an "idiomatic way to encourage people to submit description tooltip not at the source but somewhere in the main-loop. User code can peak at the payload data and generate the tooltip for it." Can you share a basic example how how you think this should work?
The idea is that as a centralized point in your application you would do:
if (const ImGuiPayload* payload == ImGui::GetDragDropPayload())
{
if (payload->IsDataType("MY_DATA_TYPE"))
{
ImGui::BeginToolTip();
//.... emit tooltip contents based on payload->Data, payload->DataSize
ImGui::EndTooltip();
}
else if (payload->IsDataType("SOME_OTHER_OF_MY_DATA_TYPE"))
{
ImGui::BeginToolTip();
//.... emit tooltip contents based on payload->Data, payload->DataSize
ImGui::EndTooltip();
}
}
Then there's no need to submit tooltip in the drag source and it works even if the drag source stops being displayed.
But, this doesn't take account of the drop target:
Ideally I want to draw the tooltip based on the currently hovered target. Most trivially I would like to draw an accept or reject icon.
At the drop target site, you can:
BeginTooltip()
to amend the tooltip submitted earlier.BeginTooltipEx(ImGuiTooltipFlags_OverridePrevious)
to ignore/clear the tooltip submitted earlier, create a new one.ImGui::SetMouseCursor(ImGuiMouseCursor_NotAllowed);
if desired.This question being old I'm not sure it matters to you much but I think that's all the answers one would need.
The ImGuiTooltipFlags_OverridePrevious
flag may be reworked later as we have some R&D API for a system of tooltip priorities to facilitate things when multiple pieces of code wants to submit a tooltip on the thing (e.g. a TabItem may use a tooltip to display an unclamped name, but we want to make it easier for use to override this without it being an append. Currently it requires ImGuiTooltipFlags_OverridePrevious
but with a priority system and good defaults in our internal widgets it would work without user intervention.
Version/Branch of Dear ImGui:
Version: 1.80 Branch: docking
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_opengl3.cpp + imgui_impl_glfw.cpp Compiler: VS2019 Operating System: Windows 10 Pro
My Issue/Question:
We discussed here how tooltips are lost when only created once by the source. https://github.com/ocornut/imgui/issues/3741
Ideally I want to draw the tooltip based on the currently hovered target. Most trivially I would like to draw an accept or reject icon. You mention an "idiomatic way to encourage people to submit description tooltip not at the source but somewhere in the main-loop. User code can peak at the payload data and generate the tooltip for it."
Can you share a basic example how how you think this should work?