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

Remap Tab key #6595

Closed
darkvad1010 opened this issue Jul 11, 2023 · 1 comment
Closed

Remap Tab key #6595

darkvad1010 opened this issue Jul 11, 2023 · 1 comment

Comments

@darkvad1010
Copy link

I was using this code to "remap" tab and shift+tab, now with the updated API, this is obsolete. I've tried to use addkeyevent but when I press the key, it repeatedly advances the cursor in a infinite loop it seems. Clearly I'm doing something wrong, not sure I have the best understanding of these functions.

// Old code:

if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_RightArrow)))
{
      g.FocusedTabPressed = true;
}

// New code:

if (ImGui::IsKeyPressed(ImGuiKey_RightArrow))
{
      io.AddKeyEvent(ImGuiKey_Tab, true); 
      ImGui::SetKeyEventNativeData(ImGuiKey_Tab, 9, 0x000F);
      io.AddKeyEvent(ImGuiKey_Tab, false);
      ImGui::SetKeyEventNativeData(ImGuiKey_Tab, 9, 0x000F);
}
@ocornut ocornut changed the title REMAP TAB KEY Remap Tab key Jul 11, 2023
@ocornut
Copy link
Owner

ocornut commented Jul 11, 2023

You'll need to either modify your backend to emit the right key, or modify the input queue after the backend submitted to it and before Dear ImGui has a chance to consume events.

You can use code like this one:
#5723 (comment)

@ocornut ocornut closed this as completed Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants