Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't select Combo with keyboard #4232

Closed
slajerek opened this issue Jun 16, 2021 · 1 comment
Closed

Can't select Combo with keyboard #4232

slajerek opened this issue Jun 16, 2021 · 1 comment
Labels
focus nav keyboard/gamepad navigation

Comments

@slajerek
Copy link

slajerek commented Jun 16, 2021

Version/Branch of Dear ImGui:

Version: 1.82 (2021/XX/XX (1.XX) - when multi-viewports are enabled....)
Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_opengl3.cpp + imgui_impl_sdl.cpp
Operating System: macOS/Windows/Linux

My Issue/Question:

I can not make Combo accessible using keyboard. I can easily move between InputInt items using TAB keyboard and enter data there using keyboard, but TAB does not stop on Combo, also I can not select items from Combo by keyboard.

I tried ImGuiConfigFlags_NavEnableKeyboard flag, however that is not correct way as this navigates using arrow keys and a spacebar, which is not default behaviour in modern OS (i.e. move focus should be achieved using TAB).

It seems Tab stop is not working for Combo.

Screenshots/Video

ezgif com-video-to-gif

Standalone, minimal, complete and verifiable example:

// Here's some code anyone can copy and paste to reproduce the issue
ImGui::Begin("Example Bug");

	static int frame = 0;
	if (frame < 2)
	{
		ImGui::SetKeyboardFocusHere();
		frame++;
	}
	
	const char *items[] = { "Item 1", "Item 2", "Item 3" };
	static int selectedItemNum = 0;
	if (ImGui::BeginCombo("combo", items[selectedItemNum]))
	{
		for (int n = 0; n < IM_ARRAYSIZE(items); n++)
		{
			bool isSelected = (selectedItemNum == n);
			if (ImGui::Selectable(items[n], isSelected))
			{
				selectedItemNum = n;
			}
			if (isSelected)
				ImGui::SetItemDefaultFocus();
		}
		ImGui::EndCombo();
	}
	
	static int val1 = 0;
	ImGui::InputInt("input 1", &val1);

	static int val2 = 0;
	ImGui::InputInt("input 2", &val2);

	static int val3 = 0;
	ImGui::InputInt("input 3", &val3);

ImGui::End();
@ocornut ocornut added nav keyboard/gamepad navigation focus labels Jun 16, 2021
@ocornut
Copy link
Owner

ocornut commented Jun 16, 2021

The nav system currently doesn't support that.
It is planned we will someday but it's not currently the case.
I've done some work on it for #4079 and a private branch but we are currently stuck finishing it due to a scrolling issue. I think tabbing should be reengineered to use same deferred logic as directional navigation.

I'll close this as duplicate of existing issues incl #3092 #3208

@ocornut ocornut closed this as completed Jun 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus nav keyboard/gamepad navigation
Projects
None yet
Development

No branches or pull requests

2 participants