imgui icon indicating copy to clipboard operation
imgui copied to clipboard

Support item hovering state in drag and drop

Open tope99 opened this issue 9 months ago • 1 comments

Version/Branch of Dear ImGui:

Version 1.91.6, Branch: docking

Back-ends:

imgui_impl_android.cpp + imgui_impl_opengl3.cpp

Compiler, OS:

Windows 10 + Android Studio

Full config/build information:

No response

Details:

My Issue/Question:

I am using drag and drop functionality to implement reordering and removal of items in a table. For a removal there is a button at the bottom of the screen (see picture).

Image

Currently AcceptDragDropPayload only supports rendering of a yellow bounding rectangle when the removal button is hovered. It would be nice to add support for ordinary hovering state so that buttons or selectables render as hovered. For example we could have a new flag ImGuiDragDropFlags_AcceptDrawHovered

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

No response

tope99 avatar May 13 '25 02:05 tope99

Apologies for my late answer. This seems sensible, I pushed b0d3c3a + bd0e203, the later adding a new ImGuiDragDropFlags_AcceptDrawAsHovered flag as suggested.

ImGui::Button("Drop Me");
if (ImGui::BeginDragDropTarget())
{
    if (ImGui::AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F, ImGuiDragDropFlags_AcceptNoDrawDefaultRect | ImGuiDragDropFlags_AcceptDrawAsHovered))
    {
       IMGUI_DEBUG_LOG("Dropped\n");
    }
    ImGui::EndDragDropTarget();
}

Please note that as #9056 you can also slightly configure the drop rect highlight, but I presume that in this sorts of case you would use ImGuiDragDropFlags_AcceptNoDrawDefaultRect anyhow.

ocornut avatar Nov 06 '25 17:11 ocornut