diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index aab1c1f69..6ac099fcf 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -69,6 +69,9 @@ Other Changes: - InputText: revert a change in 1.79 where pressing Down or PageDown on the last line of a multi-line buffer without a trailing carriage return would keep the cursor unmoved. We revert back to move to the end of line in this situation. +- Focus, InputText: fixed an issue where SetKeyboardFocusHere() did not work + on InputTextMultiline() fields with ImGuiInputTextFlags_AllowTabInput, since + they normally inhibit activation to allow tabbing through multiple items. (#8928) - Selectable: added ImGuiSelectableFlags_SelectOnNav to auto-select an item when moved into (automatic when in a BeginMultiSelect() block). - TabBar: fixed an issue were forcefully selecting a tab using internal API would diff --git a/imgui.cpp b/imgui.cpp index c655c3146..f5f018c84 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -13932,6 +13932,8 @@ void ImGui::NavMoveRequestApplyResult() { g.NavNextActivateId = result->ID; g.NavNextActivateFlags = ImGuiActivateFlags_None; + if (g.NavMoveFlags & ImGuiNavMoveFlags_FocusApi) + g.NavNextActivateFlags |= ImGuiActivateFlags_FromFocusApi; if (g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) g.NavNextActivateFlags |= ImGuiActivateFlags_PreferInput | ImGuiActivateFlags_TryToPreserveState | ImGuiActivateFlags_FromTabbing; } diff --git a/imgui_internal.h b/imgui_internal.h index 6b5b4ca25..4d54789f5 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1679,8 +1679,9 @@ enum ImGuiActivateFlags_ ImGuiActivateFlags_PreferInput = 1 << 0, // Favor activation that requires keyboard text input (e.g. for Slider/Drag). Default for Enter key. ImGuiActivateFlags_PreferTweak = 1 << 1, // Favor activation for tweaking with arrows or gamepad (e.g. for Slider/Drag). Default for Space key and if keyboard is not used. ImGuiActivateFlags_TryToPreserveState = 1 << 2, // Request widget to preserve state if it can (e.g. InputText will try to preserve cursor/selection) - ImGuiActivateFlags_FromTabbing = 1 << 3, // Activation requested by a tabbing request + ImGuiActivateFlags_FromTabbing = 1 << 3, // Activation requested by a tabbing request (ImGuiNavMoveFlags_IsTabbing) ImGuiActivateFlags_FromShortcut = 1 << 4, // Activation requested by an item shortcut via SetNextItemShortcut() function. + ImGuiActivateFlags_FromFocusApi = 1 << 5, // Activation requested by an api request (ImGuiNavMoveFlags_FocusApi) }; // Early work-in-progress API for ScrollToItem() diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 53167ea69..421f33601 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -4607,8 +4607,8 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ item_data_backup = g.LastItemData; window->DC.CursorPos = backup_pos; - // Prevent NavActivation from Tabbing when our widget accepts Tab inputs: this allows cycling through widgets without stopping. - if (g.NavActivateId == id && (g.NavActivateFlags & ImGuiActivateFlags_FromTabbing) && (flags & ImGuiInputTextFlags_AllowTabInput)) + // Prevent NavActivation from explicit Tabbing when our widget accepts Tab inputs: this allows cycling through widgets without stopping. + if (g.NavActivateId == id && (g.NavActivateFlags & ImGuiActivateFlags_FromTabbing) && !(g.NavActivateFlags & ImGuiActivateFlags_FromFocusApi) && (flags & ImGuiInputTextFlags_AllowTabInput)) g.NavActivateId = 0; // Prevent NavActivate reactivating in BeginChild() when we are already active.