Browse Source

Fix being unable to mouse wheel while dragging a payload (fix 1480bc5, #4921, #2891)

pull/5541/head
ocornut 2 years ago
parent
commit
0a4ddd7246
  1. 13
      imgui.cpp
  2. 2
      imgui.h
  3. 4
      imgui_internal.h

13
imgui.cpp

@ -3862,7 +3862,7 @@ void ImGui::StartMouseMovingWindow(ImGuiWindow* window)
g.NavDisableHighlight = true; g.NavDisableHighlight = true;
g.ActiveIdClickOffset = g.IO.MouseClickedPos[0] - window->RootWindow->Pos; g.ActiveIdClickOffset = g.IO.MouseClickedPos[0] - window->RootWindow->Pos;
g.ActiveIdNoClearOnFocusLoss = true; g.ActiveIdNoClearOnFocusLoss = true;
SetActiveIdUsingNavAndKeys(); SetActiveIdUsingAllKeyboardKeys();
bool can_move_window = true; bool can_move_window = true;
if ((window->Flags & ImGuiWindowFlags_NoMove) || (window->RootWindow->Flags & ImGuiWindowFlags_NoMove)) if ((window->Flags & ImGuiWindowFlags_NoMove) || (window->RootWindow->Flags & ImGuiWindowFlags_NoMove))
@ -5233,12 +5233,17 @@ void ImGui::SetItemUsingMouseWheel()
} }
} }
void ImGui::SetActiveIdUsingNavAndKeys() // FIXME: Technically this also prevents use of Gamepad D-Pad, may not be an issue.
void ImGui::SetActiveIdUsingAllKeyboardKeys()
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
IM_ASSERT(g.ActiveId != 0); IM_ASSERT(g.ActiveId != 0);
g.ActiveIdUsingNavDirMask = ~(ImU32)0; g.ActiveIdUsingNavDirMask = ~(ImU32)0;
g.ActiveIdUsingKeyInputMask.SetAllBits(); g.ActiveIdUsingKeyInputMask.SetBitRange(ImGuiKey_Keyboard_BEGIN, ImGuiKey_Keyboard_END);
g.ActiveIdUsingKeyInputMask.SetBit(ImGuiKey_ModCtrl);
g.ActiveIdUsingKeyInputMask.SetBit(ImGuiKey_ModShift);
g.ActiveIdUsingKeyInputMask.SetBit(ImGuiKey_ModAlt);
g.ActiveIdUsingKeyInputMask.SetBit(ImGuiKey_ModSuper);
NavMoveRequestCancel(); NavMoveRequestCancel();
} }
@ -11216,7 +11221,7 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
source_drag_active = IsMouseDragging(mouse_button); source_drag_active = IsMouseDragging(mouse_button);
// Disable navigation and key inputs while dragging + cancel existing request if any // Disable navigation and key inputs while dragging + cancel existing request if any
SetActiveIdUsingNavAndKeys(); SetActiveIdUsingAllKeyboardKeys();
} }
else else
{ {

2
imgui.h

@ -65,7 +65,7 @@ Index of this file:
// Version // Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens) // (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
#define IMGUI_VERSION "1.89 WIP" #define IMGUI_VERSION "1.89 WIP"
#define IMGUI_VERSION_NUM 18807 #define IMGUI_VERSION_NUM 18808
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx)) #define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
#define IMGUI_HAS_TABLE #define IMGUI_HAS_TABLE

4
imgui_internal.h

@ -1175,6 +1175,8 @@ enum ImGuiKeyPrivate_
{ {
ImGuiKey_LegacyNativeKey_BEGIN = 0, ImGuiKey_LegacyNativeKey_BEGIN = 0,
ImGuiKey_LegacyNativeKey_END = 512, ImGuiKey_LegacyNativeKey_END = 512,
ImGuiKey_Keyboard_BEGIN = ImGuiKey_NamedKey_BEGIN,
ImGuiKey_Keyboard_END = ImGuiKey_GamepadStart,
ImGuiKey_Gamepad_BEGIN = ImGuiKey_GamepadStart, ImGuiKey_Gamepad_BEGIN = ImGuiKey_GamepadStart,
ImGuiKey_Gamepad_END = ImGuiKey_GamepadRStickDown + 1, ImGuiKey_Gamepad_END = ImGuiKey_GamepadRStickDown + 1,
ImGuiKey_Aliases_BEGIN = ImGuiKey_MouseLeft, ImGuiKey_Aliases_BEGIN = ImGuiKey_MouseLeft,
@ -2702,7 +2704,7 @@ namespace ImGui
IMGUI_API ImGuiKeyData* GetKeyData(ImGuiKey key); IMGUI_API ImGuiKeyData* GetKeyData(ImGuiKey key);
IMGUI_API void GetKeyChordName(ImGuiModFlags mods, ImGuiKey key, char* out_buf, int out_buf_size); IMGUI_API void GetKeyChordName(ImGuiModFlags mods, ImGuiKey key, char* out_buf, int out_buf_size);
IMGUI_API void SetItemUsingMouseWheel(); IMGUI_API void SetItemUsingMouseWheel();
IMGUI_API void SetActiveIdUsingNavAndKeys(); IMGUI_API void SetActiveIdUsingAllKeyboardKeys();
inline bool IsActiveIdUsingNavDir(ImGuiDir dir) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavDirMask & (1 << dir)) != 0; } inline bool IsActiveIdUsingNavDir(ImGuiDir dir) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavDirMask & (1 << dir)) != 0; }
inline bool IsActiveIdUsingKey(ImGuiKey key) { ImGuiContext& g = *GImGui; return g.ActiveIdUsingKeyInputMask[key]; } inline bool IsActiveIdUsingKey(ImGuiKey key) { ImGuiContext& g = *GImGui; return g.ActiveIdUsingKeyInputMask[key]; }
inline void SetActiveIdUsingKey(ImGuiKey key) { ImGuiContext& g = *GImGui; g.ActiveIdUsingKeyInputMask.SetBit(key); } inline void SetActiveIdUsingKey(ImGuiKey key) { ImGuiContext& g = *GImGui; g.ActiveIdUsingKeyInputMask.SetBit(key); }

Loading…
Cancel
Save