mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-28 09:30:56 +01:00
InputText: minor tidying up.
This commit is contained in:
parent
2f9ef13be3
commit
242a52abba
@ -5342,15 +5342,15 @@ bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputT
|
|||||||
|
|
||||||
const bool is_ctrl_down = io.KeyCtrl;
|
const bool is_ctrl_down = io.KeyCtrl;
|
||||||
const bool is_shift_down = io.KeyShift;
|
const bool is_shift_down = io.KeyShift;
|
||||||
const bool tab_focus_requested = window->FocusItemRegister(g.ActiveId == id, (flags & ImGuiInputTextFlags_CallbackCompletion) == 0); // Using completion callback disable keyboard tabbing
|
const bool focus_requested = window->FocusItemRegister(g.ActiveId == id, (flags & ImGuiInputTextFlags_CallbackCompletion) == 0); // Using completion callback disable keyboard tabbing
|
||||||
//const bool align_center = (bool)(flags & ImGuiInputTextFlags_AlignCenter); // FIXME: Unsupported
|
|
||||||
|
|
||||||
const bool hovered = IsHovered(frame_bb, id);
|
const bool hovered = IsHovered(frame_bb, id);
|
||||||
if (hovered)
|
if (hovered)
|
||||||
g.HoveredId = id;
|
g.HoveredId = id;
|
||||||
|
const bool user_clicked = hovered && io.MouseClicked[0];
|
||||||
|
|
||||||
bool select_all = (g.ActiveId != id) && (flags & ImGuiInputTextFlags_AutoSelectAll) != 0;
|
bool select_all = (g.ActiveId != id) && (flags & ImGuiInputTextFlags_AutoSelectAll) != 0;
|
||||||
if (tab_focus_requested || (hovered && io.MouseClicked[0]))
|
if (focus_requested || user_clicked)
|
||||||
{
|
{
|
||||||
if (g.ActiveId != id)
|
if (g.ActiveId != id)
|
||||||
{
|
{
|
||||||
@ -5364,7 +5364,7 @@ bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputT
|
|||||||
edit_state.CursorAnimReset();
|
edit_state.CursorAnimReset();
|
||||||
edit_state.InputCursorScreenPos = ImVec2(-1.f,-1.f);
|
edit_state.InputCursorScreenPos = ImVec2(-1.f,-1.f);
|
||||||
|
|
||||||
if (tab_focus_requested || is_ctrl_down)
|
if (focus_requested || is_ctrl_down)
|
||||||
select_all = true;
|
select_all = true;
|
||||||
}
|
}
|
||||||
SetActiveId(id);
|
SetActiveId(id);
|
||||||
@ -5599,7 +5599,6 @@ bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputT
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: 'align_center' unsupported
|
|
||||||
ImGuiTextEditState::RenderTextScrolledClipped(window->Font(), window->FontSize(), buf, frame_bb.Min + style.FramePadding, w, (g.ActiveId == id) ? edit_state.ScrollX : 0.0f);
|
ImGuiTextEditState::RenderTextScrolledClipped(window->Font(), window->FontSize(), buf, frame_bb.Min + style.FramePadding, w, (g.ActiveId == id) ? edit_state.ScrollX : 0.0f);
|
||||||
|
|
||||||
if (g.ActiveId == id)
|
if (g.ActiveId == id)
|
||||||
|
1
imgui.h
1
imgui.h
@ -397,7 +397,6 @@ enum ImGuiInputTextFlags_
|
|||||||
ImGuiInputTextFlags_CallbackHistory = 1 << 7, // Call user function on pressing Up/Down arrows (for history handling)
|
ImGuiInputTextFlags_CallbackHistory = 1 << 7, // Call user function on pressing Up/Down arrows (for history handling)
|
||||||
ImGuiInputTextFlags_CallbackAlways = 1 << 8, // Call user function every time
|
ImGuiInputTextFlags_CallbackAlways = 1 << 8, // Call user function every time
|
||||||
ImGuiInputTextFlags_CallbackCharFilter = 1 << 9 // Call user function to filter character. Modify data->EventChar to replace/filter input, or return 1 to discard character.
|
ImGuiInputTextFlags_CallbackCharFilter = 1 << 9 // Call user function to filter character. Modify data->EventChar to replace/filter input, or return 1 to discard character.
|
||||||
//ImGuiInputTextFlags_AlignCenter = 1 << 6,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array
|
// User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array
|
||||||
|
Loading…
Reference in New Issue
Block a user