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

Direct keyboard access to an app's main menu. #112

Closed
JosephABudd opened this issue Sep 2, 2024 · 7 comments
Closed

Direct keyboard access to an app's main menu. #112

JosephABudd opened this issue Sep 2, 2024 · 7 comments

Comments

@JosephABudd
Copy link

Developers are probably going to find unique ways of implementing a main menu in their applications. DVUI uses the tab key very nicely, allowing the user to navigate from widget to widget.

I would like to use the [ ☰ ] key to toggle my main menu's opening and closing. Other's may want to use to key to focus and highlight their main menu.

Thoughts?

@VisenDev
Copy link
Collaborator

VisenDev commented Sep 2, 2024

Thoughts?

This might be better implemented in the application than in dvui itself
For some backends like raylib, it would be as simple as

if(c.IsKeyPressed(c.KEY_MENU)) {
    show_main_menu = !show_main_menu;
}

You should also be able to get the same keyboard control over dvui widgets this way, eg

if(try dvui.button(@src(), "(p)lay", .{}, .{}) or c.IsKeyPressed(c.KEY_M)) {
    //play
}

Edit: Are you asking how to get keyboard control over your application with dvui, or are you asking how to make dvui process a specific key?

@david-vanderson
Copy link
Owner

Is that the windows key? I thought an application couldn't change what that does (opening the start menu).

Are you able to get a key event for that button? Is there not a straightforward way to programmatically open a menu? I agree with your desire, but I'm unclear where you are getting stuck.

@JosephABudd
Copy link
Author

JosephABudd commented Sep 2, 2024

@VisenDev: I was thinking that DVUI might want to standardize a method is all. I can easily implement your second example. Thanks.
@david-vanderson: I was just thinking that DVUI might want to standardize a method. No that is the menu key.

@david-vanderson
Copy link
Owner

Oh I thought the menu key was supposed to show a context menu (same as right-clicking the mouse). We don't currently support that though.

I think the normal keyboard shortcut for getting to the menu is just pressing alt (on windows). On mac it seems to be ctrl-F2? I'm not sure it makes sense to bake in the concept of a primary menu (might be a menu per subwindow?) - but I could be wrong.

I'm very interested in seeing how it looks if you can do it with what currently exists. Can you try it and point me to the code?

@JosephABudd
Copy link
Author

I'm seeing that you are correct about the menu key works relative to what is in focus. I stand corrected. The F10 focuses the main menu. I even wrote that down yesturday. Anyway I'll work on that tomorrow.

@JosephABudd
Copy link
Author

VisenDev has it right again. Thank you VisenDev.

I'm don't want to be any more of a distraction so I'm going to let you developers work together.

@JosephABudd
Copy link
Author

VisenDev has it right again. Thank you VisenDev.

I'm don't want to be any more of a distraction so I'm going to let you developers work together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants