From a8788e51a792e42ba8c2c589044fac3291d0069e Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 5 Oct 2017 09:53:07 -0700 Subject: [PATCH] SetKeyboardFocusHere() added assert to prevent passing values smaller than -1 as we may have to outlaw them (I think nobody was using that) --- imgui.cpp | 1 + imgui.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index 1e5d128e..ad973591 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -5457,6 +5457,7 @@ void ImGui::SetScrollHere(float center_y_ratio) void ImGui::SetKeyboardFocusHere(int offset) { + IM_ASSERT(offset >= -1); // -1 is allowed but not below ImGuiWindow* window = GetCurrentWindow(); window->FocusIdxAllRequestNext = window->FocusIdxAllCounter + 1 + offset; window->FocusIdxTabRequestNext = INT_MAX; diff --git a/imgui.h b/imgui.h index 654e83fc..e47b6e9e 100644 --- a/imgui.h +++ b/imgui.h @@ -176,7 +176,7 @@ namespace ImGui IMGUI_API void SetScrollY(float scroll_y); // set scrolling amount [0..GetScrollMaxY()] IMGUI_API void SetScrollHere(float center_y_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_y_ratio=0.0: top, 0.5: center, 1.0: bottom. IMGUI_API void SetScrollFromPosY(float pos_y, float center_y_ratio = 0.5f); // adjust scrolling amount to make given position valid. use GetCursorPos() or GetCursorStartPos()+offset to get valid positions. - IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget. Use negative 'offset' to access previous widgets. + IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget. Use -1 to access previous widget. IMGUI_API void SetStateStorage(ImGuiStorage* tree); // replace tree state storage with our own (if you want to manipulate it yourself, typically clear subsection of it) IMGUI_API ImGuiStorage* GetStateStorage();