Skip to content

Add support for custom key list#1924

Closed
scottmudge wants to merge 1 commit intoocornut:masterfrom
scottmudge:custom_key_list
Closed

Add support for custom key list#1924
scottmudge wants to merge 1 commit intoocornut:masterfrom
scottmudge:custom_key_list

Conversation

@scottmudge
Copy link
Copy Markdown

This is a small change added to allow users to implement a custom key list without having to replace or modify the list in imgui.h.

Instead, they can use imconfig.h or use the preprocessor to do disable the default list and implement their own.

@ocornut
Copy link
Copy Markdown
Owner

ocornut commented Jul 4, 2018

How are you using this? Is the intent to be able to write keyboard-interface that don’t rely on the native KeysDown[] order?

I think we ought to populate this list properly and I’d perhaps even consider removing the mapping step at all.

@scottmudge
Copy link
Copy Markdown
Author

Yes, the intent is to use other hot-keys or keys beyond A,C,V,X,Y,Z that are currently provided -- any other alpha or numeric keys, function keys, and so on.

I have been previously copying-and-pasting over the ImGuiKey_ enum to add more, but I did not find this a tenable solution as I continue to download and merge new versions of ImGui.

@ocornut
Copy link
Copy Markdown
Owner

ocornut commented Jul 4, 2018 via email

@scottmudge
Copy link
Copy Markdown
Author

Well my initial intention was to keep it coherent across the entire ImGui namespace, even in my own widgets which extend the ImGui namespace and require additional keys. But you're right that if I'm only implementing the additional enums in my own widgets that are declared in files outside of the imgui base, it doesn't really matter anyway.

At the very least it could be a soft-bridge between populating the list entirely (or at least with a full alpha-numeric list), or removing it entirely.

@ocornut
Copy link
Copy Markdown
Owner

ocornut commented Jul 4, 2018

Thanks for the clarification.

I want to populate this list but will probably bundle that change when I have a better understanding of how we are going to handle shortcuts and keyboard internationalization (under various frameworks it is not easy to retrieve characters when e.g. a CTRL modifier key is held, requiring us to rely on keys instead of characters, but those are often derived from non-localized scan codes).

I have been previously copying-and-pasting over the ImGuiKey_ enum to add more, but I did not find this a tenable solution as I continue to download and merge new versions of ImGui.

In the meanwhile, may I suggest you use the strategy proposed in your PR and you only have to merge in the 2 lines (#ifndef and #endif) in imgui.h for now? You can apply a patch automatically post update if you don't want to be git merging.

@ocornut
Copy link
Copy Markdown
Owner

ocornut commented Jun 14, 2019

Closing this as I think we'll more probably aim straight for something like #2625

@ocornut ocornut closed this Jun 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants