Skip to content

Instantly share code, notes, and snippets.

@ocornut
Last active September 12, 2025 18:04
Show Gist options
  • Save ocornut/72dff3fff224205f4b7149708c629d4c to your computer and use it in GitHub Desktop.
Save ocornut/72dff3fff224205f4b7149708c629d4c to your computer and use it in GitHub Desktop.
// Small hack for a resizable InputTextMultiline()
ImVec2 SetInputTextMultilineResizableY(const char* label, const ImVec2& base_size)
{
ImVec2 pos = ImGui::GetCursorScreenPos();
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, { 0.0f, 0.0f });
ImGui::BeginChild(label, base_size, ImGuiChildFlags_ResizeY | ImGuiChildFlags_FrameStyle | ImGuiChildFlags_Borders);
ImVec2 actual_size = ImGui::GetWindowSize();
ImGui::EndChild();
ImGui::PopStyleVar();
ImGui::SetCursorScreenPos(pos);
return actual_size;
}
// Usage
static char buf[10000] = "";
ImVec2 size = SetInputTextMultilineResizableY("##test", { -FLT_MIN, 200.0f });
ImGui::InputTextMultiline("##test", buf, IM_ARRAYSIZE(buf), size);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment