Test if mouse cursor is hovering given rectangle NB- Rectangle is clipped by our current clip setting NB- Expand the rectangle to be generous on imprecise inputs systems (g.Style.TouchExtraPadding)
| 8341 | // NB- Rectangle is clipped by our current clip setting |
| 8342 | // NB- Expand the rectangle to be generous on imprecise inputs systems (g.Style.TouchExtraPadding) |
| 8343 | bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip) |
| 8344 | { |
| 8345 | ImGuiContext& g = *GImGui; |
| 8346 | |
| 8347 | // Clip |
| 8348 | ImRect rect_clipped(r_min, r_max); |
| 8349 | if (clip) |
| 8350 | rect_clipped.ClipWith(g.CurrentWindow->ClipRect); |
| 8351 | |
| 8352 | // Expand for touch input |
| 8353 | const ImRect rect_for_touch(rect_clipped.Min - g.Style.TouchExtraPadding, rect_clipped.Max + g.Style.TouchExtraPadding); |
| 8354 | if (!rect_for_touch.Contains(g.IO.MousePos)) |
| 8355 | return false; |
| 8356 | return true; |
| 8357 | } |
| 8358 | |
| 8359 | // Return if a mouse click/drag went past the given threshold. Valid to call during the MouseReleased frame. |
| 8360 | // [Internal] This doesn't test if the button is pressed |