MCPcopy Create free account
hub / github.com/GPUOpen-LibrariesAndSDKs/Cauldron / InputTextEx

Method InputTextEx

libs/imgui/imgui.cpp:8403–8986  ·  view source on GitHub ↗

Edit a string of text NB: when active, hold on a privately held copy of the text (and apply back to 'buf'). So changing 'buf' while active has no effect. FIXME: Rather messy function partly because we are doing UTF8 > u16 > UTF8 conversions on the go to more easily handle stb_textedit calls. Ideally we should stay in UTF-8 all the time. See https://github.com/nothings/stb/issues/188

Source from the content-addressed store, hash-verified

8401// NB: when active, hold on a privately held copy of the text (and apply back to 'buf'). So changing 'buf' while active has no effect.
8402// FIXME: Rather messy function partly because we are doing UTF8 > u16 > UTF8 conversions on the go to more easily handle stb_textedit calls. Ideally we should stay in UTF-8 all the time. See https://github.com/nothings/stb/issues/188
8403bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiTextEditCallback callback, void* user_data)
8404{
8405 ImGuiWindow* window = GetCurrentWindow();
8406 if (window->SkipItems)
8407 return false;
8408
8409 IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackHistory) && (flags & ImGuiInputTextFlags_Multiline))); // Can't use both together (they both use up/down keys)
8410 IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackCompletion) && (flags & ImGuiInputTextFlags_AllowTabInput))); // Can't use both together (they both use tab key)
8411
8412 ImGuiContext& g = *GImGui;
8413 const ImGuiIO& io = g.IO;
8414 const ImGuiStyle& style = g.Style;
8415
8416 const bool is_multiline = (flags & ImGuiInputTextFlags_Multiline) != 0;
8417 const bool is_editable = (flags & ImGuiInputTextFlags_ReadOnly) == 0;
8418 const bool is_password = (flags & ImGuiInputTextFlags_Password) != 0;
8419 const bool is_undoable = (flags & ImGuiInputTextFlags_NoUndoRedo) == 0;
8420
8421 if (is_multiline) // Open group before calling GetID() because groups tracks id created during their spawn
8422 BeginGroup();
8423 const ImGuiID id = window->GetID(label);
8424 const ImVec2 label_size = CalcTextSize(label, NULL, true);
8425 ImVec2 size = CalcItemSize(size_arg, CalcItemWidth(), (is_multiline ? GetTextLineHeight() * 8.0f : label_size.y) + style.FramePadding.y*2.0f); // Arbitrary default of 8 lines high for multi-line
8426 const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + size);
8427 const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? (style.ItemInnerSpacing.x + label_size.x) : 0.0f, 0.0f));
8428
8429 ImGuiWindow* draw_window = window;
8430 if (is_multiline)
8431 {
8432 if (!BeginChildFrame(id, frame_bb.GetSize()))
8433 {
8434 EndChildFrame();
8435 EndGroup();
8436 return false;
8437 }
8438 draw_window = GetCurrentWindow();
8439 size.x -= draw_window->ScrollbarSizes.x;
8440 }
8441 else
8442 {
8443 ItemSize(total_bb, style.FramePadding.y);
8444 if (!ItemAdd(total_bb, id))
8445 return false;
8446 }
8447 const bool hovered = ItemHoverable(frame_bb, id);
8448 if (hovered)
8449 g.MouseCursor = ImGuiMouseCursor_TextInput;
8450
8451 // Password pushes a temporary font with only a fallback glyph
8452 if (is_password)
8453 {
8454 const ImFontGlyph* glyph = g.Font->FindGlyph('*');
8455 ImFont* password_font = &g.InputTextPasswordFont;
8456 password_font->FontSize = g.Font->FontSize;
8457 password_font->Scale = g.Font->Scale;
8458 password_font->DisplayOffset = g.Font->DisplayOffset;
8459 password_font->Ascent = g.Font->Ascent;
8460 password_font->Descent = g.Font->Descent;

Callers

nothing calls this directly

Calls 15

GetCurrentWindowFunction · 0.85
ImVec2Class · 0.85
ImStrncpyFunction · 0.85
ImTextStrFromUtf8Function · 0.85
stb_textedit_clickFunction · 0.85
stb_textedit_dragFunction · 0.85
InputTextFilterCharacterFunction · 0.85
IsKeyPressedMapFunction · 0.85
SetWindowScrollYFunction · 0.85
ImMaxFunction · 0.85
ImMinFunction · 0.85

Tested by

no test coverage detected