Fix tabbing in/out of an InputTextMultiline(), broken by 6b8a059.

docking
ocornut 3 years ago
parent cd39460925
commit 161b74e871

@ -3966,6 +3966,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
ImGuiWindow* draw_window = window; ImGuiWindow* draw_window = window;
ImVec2 inner_size = frame_size; ImVec2 inner_size = frame_size;
ImGuiItemStatusFlags item_status_flags = 0;
if (is_multiline) if (is_multiline)
{ {
if (!ItemAdd(total_bb, id, &frame_bb, ImGuiItemAddFlags_Focusable)) if (!ItemAdd(total_bb, id, &frame_bb, ImGuiItemAddFlags_Focusable))
@ -3974,6 +3975,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
EndGroup(); EndGroup();
return false; return false;
} }
item_status_flags = g.LastItemData.StatusFlags;
// We reproduce the contents of BeginChildFrame() in order to provide 'label' so our window internal data are easier to read/debug. // We reproduce the contents of BeginChildFrame() in order to provide 'label' so our window internal data are easier to read/debug.
PushStyleColor(ImGuiCol_ChildBg, style.Colors[ImGuiCol_FrameBg]); PushStyleColor(ImGuiCol_ChildBg, style.Colors[ImGuiCol_FrameBg]);
@ -4000,6 +4002,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
if (!(flags & ImGuiInputTextFlags_MergedItem)) if (!(flags & ImGuiInputTextFlags_MergedItem))
if (!ItemAdd(total_bb, id, &frame_bb, ImGuiItemAddFlags_Focusable)) if (!ItemAdd(total_bb, id, &frame_bb, ImGuiItemAddFlags_Focusable))
return false; return false;
item_status_flags = g.LastItemData.StatusFlags;
} }
const bool hovered = ItemHoverable(frame_bb, id); const bool hovered = ItemHoverable(frame_bb, id);
if (hovered) if (hovered)
@ -4008,8 +4011,8 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
// We are only allowed to access the state if we are already the active widget. // We are only allowed to access the state if we are already the active widget.
ImGuiInputTextState* state = GetInputTextState(id); ImGuiInputTextState* state = GetInputTextState(id);
const bool focus_requested_by_code = (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_FocusedByCode) != 0; const bool focus_requested_by_code = (item_status_flags & ImGuiItemStatusFlags_FocusedByCode) != 0;
const bool focus_requested_by_tabbing = (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_FocusedByTabbing) != 0; const bool focus_requested_by_tabbing = (item_status_flags & ImGuiItemStatusFlags_FocusedByTabbing) != 0;
const bool user_clicked = hovered && io.MouseClicked[0]; const bool user_clicked = hovered && io.MouseClicked[0];
const bool user_nav_input_start = (g.ActiveId != id) && ((g.NavInputId == id) || (g.NavActivateId == id && g.NavInputSource == ImGuiInputSource_Keyboard)); const bool user_nav_input_start = (g.ActiveId != id) && ((g.NavInputId == id) || (g.NavActivateId == id && g.NavInputSource == ImGuiInputSource_Keyboard));

Loading…
Cancel
Save