Shortcuts without Menuitem

Back on a Xojo project after a few months. I feel like I’ve forgotten everything. :slight_smile:

For different listboxes, I need to setup a whole bunch of shortcuts. Option-V, Option-A, Option-I etc.

I tried AsyncKey and checking for Asc(key) = nn in the Keydown but it feels odd because Option-V comes back as the ?, Option-A as and Option-I as . Is that the way to do it?

The App is localized in 20 languages so (unless they can stay hidden) I would like to prevent using Menuitems.

Edit:
Hmm… Now I’m lost. Just tried capturing the Asc and AscB of the Keys (like I normally do with arrow keys etc.) but it doesn’t seem to work that way with the Option key pressed.

System.DebugLog(Str(Asc(Key)))
Option-I = 0
Option-U = 0
Option-W = 8721
Option-A = 229
Option-S = 223
Option-M = 181

System.DebugLog(StrB(Asc(Key)))
Option-I = 0
Option-U = 0
Option-W = 226
Option-A = 195
Option-S = 195
Option-M = 194

go ahead and create real menus, with the short cuts
then in app.open… set the visible=false on all of them.
the short cuts should still work… just make sure you set VISIBLE and NOT the ENABLED property

That would be great but are you sure that works?
The shortcuts work but as soon as I set it visible = false (in Window.Open), it won’t take the shortcut anymore. I tried the Menu, the MenuItem & both.

I would not go the keydown or keyboard class route for a multilingual app. Option is a modifier for the keyboard so indeed it changes the key. And in multilingual settings, Option-A can be anything. For instance Option-a is in a French layout and in a US layout.

On Mac, the keyboard class is not localized (asyncKeydown) , so the upper-left corner of the typewriter keyboard is always &h0C no matter the language, would it be the a key in French or q in the US. In a multilingual settings it becomes impossible to deal with. I would not go that route either. Unless you are ready to patiently collect layouts for each keyboard. And yet, for instance Canadian French is Qwerty while France French is Azerty so you would have to detect the keyboard, on top of detecting the language.

The nice thing about keyboard shortcuts is that all these pitfalls are taken care of.
I don’t think you can avoid showing the menu if you want the shortcuts. The best you could do is have a menubar item called " ". Or, why not “Shortcuts”. After all, that is a nice way to provide discoverable.

You are right about the keyboard layouts.
My main issue with MenuItems is that if I show them, I need to go through the hassle of translating.

I’m basically looking for a way like Xojo has. The Editor has Shortcuts that aren’t showing in any Menuitems. Like Option-Delete, Option-Backspace, Shift-Enter etc.

I think on Windows, you can assign a Shortcut to a Button that can be placed outside the window.
Dave’s suggestion would be great but I can’t get it to work somehow.

How are you localizing your app if menu items are a problem? You can set menu items to display dynamic constant values.

Of course I use dynamic constants. It’s about having 15 shortcuts (* 20 languages) that don’t need to be in a Menu.

Oh I never considered that the shortcuts would be localized. I kind of assumed that shortcuts were the same no matter which language was displayed (like in every app.)

Does anyone know about that? Is there like a noticeable difference in companies that localize shortcuts and others that don’t really care?

The MS Word shorcut for Save in the English version is Ctrl+S, in the Spanish version it is Ctrl+G. Many more vary, this is not the only example.

[quote=309331:@Tim Parnell]Oh I never considered that the shortcuts would be localized. I kind of assumed that shortcuts were the same no matter which language was displayed (like in every app.)

Does anyone know about that? Is there like a noticeable difference in companies that localize shortcuts and others that don’t really care?[/quote]

I was going to tell for Microsoft, but Julen beat me to it. Shortcut should be easily memorizable. If in France “Sauve” is the same as “Save”, for instance, “Imprime” in French or “Imprimir” in Spanish are definitely not the same as “Print”, so one would expect the shortcut to be Cmd-I or Ctrl-I instead of Cmd-P or Ctrl-P.

Some companies insist of being anglo-centric, but then the shortcut bear little resemblance to what is written in menus. Wordperfect being one of them. As a result shortcut are barely usable, and I know of very little users who can memorize more than 4 or 5.

Finally, there are shortcuts that never change, such as system one like Cmd/Ctrl-C, Cmd/Ctrl-X and Cmd/Ctrl-V.

[quote=309305:@Marco Hof]System.DebugLog(Str(Asc(Key)))
Option-I = 0
Option-U = 0
Option-W = 8721
Option-A = 229
Option-S = 223
Option-M = 181

System.DebugLog(StrB(Asc(Key)))
Option-I = 0
Option-U = 0
Option-W = 226
Option-A = 195
Option-S = 195
Option-M = 194[/quote]
Marco - poking in the dark here, but is it possible that you’re getting 0 back for I and U because the system has then mapped globally and is catching them before they get to your app?

Also note that on a Mac a user can only change keyboard shortcuts for an application if a menu item exists, so it is advisable to have menu items for all keyboard shortcuts.