mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Drag and Drop: Fixed using BeginDragDropSource() within a Begin()/BeginChild() that returned false. (#4515) + BeginDragDropTarget()
Note how 79ae6d3b
adedd a SkipItems test in BeginDragDropTargetCustom() only.
Catching this similar to work needed to neatly represent the error in #4375 #4158, #4008, #2562
This commit is contained in:
parent
bd6c9e99fc
commit
607ad8c949
@ -52,6 +52,7 @@ Other Changes:
|
||||
- Nav: Fixed toggling menu layer with Alt or exiting menu layer with Esc not moving mouse when
|
||||
the NavEnableSetMousePos config flag is set.
|
||||
- Menus: adjust closing logic to accomodate for varying font size and dpi.
|
||||
- Drag and Drop: Fixed using BeginDragDropSource() inside a BeginChild() that returned false. (#4515)
|
||||
- PlotHistogram: Fixed zero-line position when manually specifying min<0 and max>0. (#4349) [@filippocrocchini]
|
||||
- IO: Added 'io.WantCaptureMouseUnlessPopupClose' alternative to `io.WantCaptureMouse'. (#4480)
|
||||
This allows apps to receive the click on void when that click is used to close popup (by default,
|
||||
|
13
imgui.cpp
13
imgui.cpp
@ -7813,6 +7813,7 @@ ImVec2 ImGui::GetWindowContentRegionMax()
|
||||
|
||||
// Lock horizontal starting position + capture group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.)
|
||||
// Groups are currently a mishmash of functionalities which should perhaps be clarified and separated.
|
||||
// FIXME-OPT: Could we safely early out on ->SkipItems?
|
||||
void ImGui::BeginGroup()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -9978,14 +9979,16 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
|
||||
return false;
|
||||
if (g.ActiveIdMouseButton != -1)
|
||||
mouse_button = g.ActiveIdMouseButton;
|
||||
if (g.IO.MouseDown[mouse_button] == false)
|
||||
if (g.IO.MouseDown[mouse_button] == false || window->SkipItems)
|
||||
return false;
|
||||
g.ActiveIdAllowOverlap = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Uncommon path: items without ID
|
||||
if (g.IO.MouseDown[mouse_button] == false)
|
||||
if (g.IO.MouseDown[mouse_button] == false || window->SkipItems)
|
||||
return false;
|
||||
if ((g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HoveredRect) == 0 && (g.ActiveId == 0 || g.ActiveIdWindow != window))
|
||||
return false;
|
||||
|
||||
// If you want to use BeginDragDropSource() on an item with no unique identifier for interaction, such as Text() or Image(), you need to:
|
||||
@ -9996,10 +9999,6 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Early out
|
||||
if ((g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HoveredRect) == 0 && (g.ActiveId == 0 || g.ActiveIdWindow != window))
|
||||
return false;
|
||||
|
||||
// Magic fallback (=somehow reprehensible) to handle items with no assigned ID, e.g. Text(), Image()
|
||||
// We build a throwaway ID based on current ID stack + relative AABB of items in window.
|
||||
// THE IDENTIFIER WON'T SURVIVE ANY REPOSITIONING OF THE WIDGET, so if your widget moves your dragging operation will be canceled.
|
||||
@ -10165,7 +10164,7 @@ bool ImGui::BeginDragDropTarget()
|
||||
if (!(g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HoveredRect))
|
||||
return false;
|
||||
ImGuiWindow* hovered_window = g.HoveredWindowUnderMovingWindow;
|
||||
if (hovered_window == NULL || window->RootWindow != hovered_window->RootWindow)
|
||||
if (hovered_window == NULL || window->RootWindow != hovered_window->RootWindow || window->SkipItems)
|
||||
return false;
|
||||
|
||||
const ImRect& display_rect = (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HasDisplayRect) ? g.LastItemData.DisplayRect : g.LastItemData.Rect;
|
||||
|
Loading…
Reference in New Issue
Block a user