diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 97871ceb..dbe87c97 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -64,6 +64,7 @@ Other Changes: - PlotLines, PlotHistogram: Ignore NaN values when calculating min/max bounds. (#2485) - Columns: Fixed boundary of clipping being off by 1 pixel within the left column. - Combo, Slider, Scrollbar: Improve rendering in situation when there's only a few pixels available (<3 pixels). +- Nav: Fixed Drag/Slider functions going into text input mode when keyboard CTRL is held while pressing NavActivate. - Misc: Added IM_MALLOC/IM_FREE macros mimicking IM_NEW/IM_DELETE so user doesn't need to revert to using the ImGui::MemAlloc()/MemFree() calls directly. - Metrics: Added "Show windows rectangles" tool to visualize the different rectangles. diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 9b212545..bebbf3d8 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -2004,13 +2004,15 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* v, floa if (!temp_input_is_active) { const bool focus_requested = FocusableItemRegister(window, id); - if (focus_requested || (hovered && (g.IO.MouseClicked[0] || g.IO.MouseDoubleClicked[0])) || g.NavActivateId == id || g.NavInputId == id) + const bool clicked = (hovered && g.IO.MouseClicked[0]); + const bool double_clicked = (hovered && g.IO.MouseDoubleClicked[0]); + if (focus_requested || clicked || double_clicked || g.NavActivateId == id || g.NavInputId == id) { SetActiveID(id, window); SetFocusID(id, window); FocusWindow(window); g.ActiveIdAllowNavDirFlags = (1 << ImGuiDir_Up) | (1 << ImGuiDir_Down); - if (focus_requested || g.IO.KeyCtrl || g.IO.MouseDoubleClicked[0] || g.NavInputId == id) + if (focus_requested || (clicked && g.IO.KeyCtrl) || double_clicked || g.NavInputId == id) { temp_input_start = true; FocusableItemUnregister(window); @@ -2447,13 +2449,14 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* v, co if (!temp_input_is_active) { const bool focus_requested = FocusableItemRegister(window, id); - if (focus_requested || (hovered && g.IO.MouseClicked[0]) || g.NavActivateId == id || g.NavInputId == id) + const bool clicked = (hovered && g.IO.MouseClicked[0]); + if (focus_requested || clicked || g.NavActivateId == id || g.NavInputId == id) { SetActiveID(id, window); SetFocusID(id, window); FocusWindow(window); g.ActiveIdAllowNavDirFlags = (1 << ImGuiDir_Up) | (1 << ImGuiDir_Down); - if (focus_requested || g.IO.KeyCtrl || g.NavInputId == id) + if (focus_requested || (clicked && g.IO.KeyCtrl) || g.NavInputId == id) { temp_input_start = true; FocusableItemUnregister(window);