Internals: Added GetInputTextState() + comments.

This commit is contained in:
ocornut
2020-03-07 15:55:05 +01:00
parent 2dcf8df9f4
commit aef057e975
5 changed files with 13 additions and 9 deletions

View File

@ -3516,10 +3516,8 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
if (hovered)
g.MouseCursor = ImGuiMouseCursor_TextInput;
// NB: we are only allowed to access 'edit_state' if we are the active widget.
ImGuiInputTextState* state = NULL;
if (g.InputTextState.ID == id)
state = &g.InputTextState;
// We are only allowed to access the state if we are already the active widget.
ImGuiInputTextState* state = GetInputTextState(id);
const bool focus_requested = FocusableItemRegister(window, id);
const bool focus_requested_by_code = focus_requested && (g.FocusRequestCurrWindow == window && g.FocusRequestCurrCounterRegular == window->DC.FocusCounterRegular);