Skip to content

Commit

Permalink
Drag and Drop, Nav: Disabling navigation arrow keys when drag and dro…
Browse files Browse the repository at this point in the history
…p is active. (#3025)
  • Loading branch information
ocornut committed Feb 17, 2020
1 parent b62f1ea commit 8836975
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ HOW TO UPDATE?

Other Changes:

- Drag and Drop, Nav: Disabling navigation arrow keys when drag and drop is active. In the docking
branch pressing arrow keys while dragging a window from a tab could trigger an assert. (#3025)
- ColorButton: Added ImGuiColorEditFlags_NoBorder flag to remove the border normally enforced
by default for standalone ColorButton.
- InputText: Fixed password fields displaying ASCII spaces as blanks instead of using the '*'
Expand Down
8 changes: 8 additions & 0 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3254,6 +3254,9 @@ void ImGui::StartMouseMovingWindow(ImGuiWindow* window)

// Handle mouse moving window
// Note: moving window with the navigation keys (Square + d-pad / CTRL+TAB + Arrows) are processed in NavUpdateWindowing()
// FIXME: We don't have strong guarantee that g.MovingWindow stay synched with g.ActiveId == g.MovingWindow->MoveId.
// This is currently enforced by the fact that BeginDragDropSource() is setting all g.ActiveIdUsingXXXX flags to inhibit navigation inputs,
// but if we should more thoroughly test cases where g.ActiveId or g.MovingWindow gets changed and not the other.
void ImGui::UpdateMouseMovingWindowNewFrame()
{
ImGuiContext& g = *GImGui;
Expand Down Expand Up @@ -8999,6 +9002,11 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
return false;
source_parent_id = window->IDStack.back();
source_drag_active = IsMouseDragging(mouse_button);

// Disable navigation and key inputs while dragging
g.ActiveIdUsingNavDirMask = ~(ImU32)0;
g.ActiveIdUsingNavInputMask = ~(ImU32)0;
g.ActiveIdUsingKeyInputMask = ~(ImU64)0;
}
else
{
Expand Down

0 comments on commit 8836975

Please sign in to comment.