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

Adding Underlines for Alt key shortcuts in ImGui File Menu #6323

Closed
marzRX opened this issue Apr 12, 2023 · 4 comments
Closed

Adding Underlines for Alt key shortcuts in ImGui File Menu #6323

marzRX opened this issue Apr 12, 2023 · 4 comments

Comments

@marzRX
Copy link

marzRX commented Apr 12, 2023

Version/Branch of Dear ImGui:
Version: 1.89
Branch: master

Back-end/Renderer/Compiler/OS
Back-end: GLFW + OpenGL3
Compiler: g++(MinGW)
OS: windows7

My Question:
I have a question about the file menu of ImGui. I understand how to use shortcut keys such as Ctrl+O and Ctrl+S, but I would like to know how to add an underline to the F in "File" and the E in "Edit" on the menu items. I would like to be able to open the file menu with Alt+F. In code, this feature can be achieved by writing "&File" or "&Edit". How can I represent this feature in ImGui?

@ocornut
Copy link
Owner

ocornut commented Apr 12, 2023

It is not currently possible other than yourself manually drawing a line (which involve calculating position of a given character).
This will be part of work for #456 but not currently done and if we adopt Windows's convention we may need low-level support in the text rendering routines.

@marzRX
Copy link
Author

marzRX commented Apr 12, 2023

Thank you for your response. I understand it is not currently supported.
I've seen #126 before, though it's also linked from #456. So, I just wondered if that would allow me to do it, so I asked. :)

@marzRX marzRX closed this as completed Apr 12, 2023
@ocornut
Copy link
Owner

ocornut commented Apr 12, 2023

FYI this is in my checklist for the new text functions I've been writing (I put a few weeks of work on them several months ago but then had to prioritize other things).

If we decide to restrict that feature to MenuItem inside menus, we can easily do some adhoc parsing there and it doesn't even need to be super-efficient, but my hope was that this could ideally be supported more globally (e.g. ImGui::Button("&Save"); in a regular window) where it would need a little bit more low-level system. Ideally at the same time we perform a CalcTextSize() for layout we extract this data. It also means we need an optimal scheme for still allowing a & to be expressed e.g. \\& or && before a letter.

@marzRX
Copy link
Author

marzRX commented Apr 13, 2023

Thank you for sharing this information. I am not in a hurry. I am looking forward to the new text functions, including the implementation of the underlined Alt key shortcuts.

Recently, I've noticed that some applications do not support Alt key shortcuts. I personally find them very useful and convenient, as I use them quite often.

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