OSX menus shorcuts

Is there a way to assign a shortcut without the command?

If assigned, for example, the N to an item, even if “menu modifier” is not checked, when the app runs the menu shows command-n.

Moreover, if you want to use a “h”, for example it doesn’t show because apple Hide App takes preference. Can this be disabled?

You can assign a new shortcut in code without the Command modifier, e.g.

FileOpen.Shortcut = “Shift-O”

However, such shortcut produces a valid string when typed, so it will be intercepted by any focused TextEdit object in the active window. The same happens with Option as the modifier.

As a whole, I would strongly advice you not to mess with system-defined shortcuts as macOS users are pretty unforgiving towards applications which do not obey the macOS look-and-feel.

1 Like

Clarifying, in the editor:


Event Open Window:
ActionHide.Shortcut= “H”
Does not make any effect

pretty sure you can’t do this on a mac. at least with xojo.
you can of course use a keydown event to make the action you want , but in the menus the cmd key is mandatory.

OK, when you give only a letter, Xojo adds Command in front of it.

In order to force “no modifier”, you need to use “-O” instead but you need to do it in code (I’ve just tried it).

EDIT: you can also use “-O” in the editor but you need to set MenuModifier to off for it to work.

1 Like

Thanks Stéphane, “-O” works fine to avoid the Command.

Unfortunately not for take over the “h” used for the Finder. The finder uses command-H to hide application, I use only “h” for an action, but -Oh dont work here.

Thanks Jean-Yves, I already use keydown to intercept the choosed action, but I wished to have also a menu with all shortcuts, as a facility to the user.

Really? -H works fine for me (Xojo 2019r1.1 on macOS 10.14.4)

You’re right “-H” works but not “-OH” that works in the other cases.

“-OH” ? That is not supposed to work

I misundertood your first post and I asumed I should use “-O” and the key, So, to use the letter A I should use “-Oa”.
Now is clear, thenk you

For your information, the Finder doesn’t use command-H differently than any other application (which it is as well). The OS does.

And, as Stéphane mentioned, having a different behaviour with your app like using Command-H is probably not a good thing.
Being a user who use the keyboard most of the time, I usually trash an application which messes with usual shortcuts, even if it could be a good one.

1 Like

The app I’m developing is a game, with many actions and shortcuts.
In the game you may use the keyboard keys for actions, not the usual OS command-keys, so, using “h” or “s” doesn’t interferes with the standard Hide App or Save.
My problem was that I did know how to create menu options without the added command.

Yes, and I’m glad you got an answer for your question.
Still, it’s important to think as the final user and wonder whether they’ll feel comfortable with your tweaks.

Sure, but as it’s a game where you don’t write text, or feed text fields, just acts. Then I believe, the actions like “go to next unit” -> N, go to previous -> P, or hide units -> H, etc., are comfortable for the user.

Are you using just H or command+H? I’m confused.

I’m using just the key in each case.

There are a few different ways to capture keys for games. There’s even a whole folder in Example Projects called Games. Start there.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.