epezent / implot

Immediate Mode Plotting
MIT License
4.55k stars 503 forks source link

Detect ImPlot::DragPoint is activated, deactivate and hovered #477

Closed cingelmarekmt closed 11 months ago

cingelmarekmt commented 1 year ago

Hi,

What needs to be done to find out if the point has been clicked? I tried this but it doesn't work:

if (ImPlot::DragPoint(index * 4 + 0, &p0.x, &p0.y, isActive ? ImVec4(1, 0, 0, 1) : ImVec4(0, 1, 0, 1), 4, flags))
{
     // TODO move point
}
if (!ImPlot::IsPlotHovered() &&
    ImGui::IsItemReleased(ImGuiMouseButton_Left) &&
    ImGui::IsItemHovered(ImGuiHoveredFlags_None))
{
     // TODO activate point (change color) or delete point from plot
}

Is there an example?

Thank you for your response

epezent commented 11 months ago

This is beyond the current scope of DragPoint. For more sophisticated input handling, I suggest you create your own version of this function. It is a very small amount of code.