Browse Source

InputText: minor tidying up.

pull/142/head
ocornut 10 years ago
parent
commit
242a52abba
  1. 9
      imgui.cpp
  2. 1
      imgui.h

9
imgui.cpp

@ -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_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 align_center = (bool)(flags & ImGuiInputTextFlags_AlignCenter); // FIXME: Unsupported
const bool focus_requested = window->FocusItemRegister(g.ActiveId == id, (flags & ImGuiInputTextFlags_CallbackCompletion) == 0); // Using completion callback disable keyboard tabbing
const bool hovered = IsHovered(frame_bb, id);
if (hovered)
g.HoveredId = id;
const bool user_clicked = hovered && io.MouseClicked[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)
{
@ -5364,7 +5364,7 @@ bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputT
edit_state.CursorAnimReset();
edit_state.InputCursorScreenPos = ImVec2(-1.f,-1.f);
if (tab_focus_requested || is_ctrl_down)
if (focus_requested || is_ctrl_down)
select_all = true;
}
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);
if (g.ActiveId == id)

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_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_AlignCenter = 1 << 6,
};
// User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array

Loading…
Cancel
Save