Skip to content

Input fields do not keep focus when used in tables #5729

Closed
@danbrown3

Description

Version/Branch of Dear ImGui:

Version: v1.85
Branch: Not sure

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_win32.cpp
Operating System: Windows

My Issue/Question:

When using inputs in a table (I tested with InputInt), the text field does not keep focus in between frames.

Standalone, minimal, complete and verifiable example: (see #2261)

const int numCols = 3;
static ImGuiTableFlags flags = ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg;
if (ImGui::BeginTable("TrackerTable", numCols, flags))
{
	ImGui::TableSetupColumn("Title", ImGuiTableColumnFlags_WidthFixed);
	ImGui::TableSetupColumn("Tracking Type", ImGuiTableColumnFlags_WidthFixed);
	ImGui::TableSetupColumn("Current Value", ImGuiTableColumnFlags_WidthFixed, 100);

	ImGui::TableHeadersRow();

	for (auto& myThing : m_myThings)
	{
		ImGui::TableNextRow();
		ImGui::TableNextColumn();

		//Title
		ImGui::Text("%s", myThing.title);
		ImGui::TableNextColumn();
		
		//Tracking Type
		ImGui::Text("Int");
		ImGui::TableNextColumn();

		//Current Value
		ImGui::InputInt("", &myThing.intVal);
		ImGui::TableNextColumn();
	}

	ImGui::EndTable();
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions