How should I handle shortcuts on the mac?
BlitzMax Forums/BlitzMax Programming/How should I handle shortcuts on the mac?
| ||
On windows, I would write this:Menu_Open = CreateMenu("Open..."+Chr$(8)+"Ctrl+O", 1, Menu_File) CreateMenu("", 0, Menu_File) Menu_Save = CreateMenu("Save..."+Chr$(8)+"Ctrl+S", 5, Menu_File) CreateMenu("", 0, Menu_File) 'Menu_Batch = CreateMenu("Batch...", 2, Menu_File) 'CreateMenu("", 0, Menu_File) Menu_Quit = CreateMenu("Quit"+Chr$(8)+"Ctrl+Q", 99, Menu_File) But on the Mac, the shortcuts would be Command-Whatever. And on a Mac, the word Command isn't written out, but rather is represented with a little icon: So how do you get that little icon? |
| ||
It's U+2318 according to Wikipedia, so there you go. |
| ||
Thanks! Hm, so, something like this should do the trick: ?MacOS Const SHORTCUT_PREFIX$ = Chr($2318) Const SHORTCUT_MODIFIER% = MODIFIER_COMMAND ?Not MacOS Const SHORTCUT_PREFIX$ = "Ctrl+" Const SHORTCUT_MODIFIER% = MODIFIER_CONTROL ? Although I can't get that character to display as the command character in Windows. It displays as a note in Firefox, and as a Chinese symbol in BlitzMax. So I can't be sure I've set it right. |
| ||
Although I can't get that character to display as the command character in Windows. It displays as a note in Firefox, and as a Chinese symbol in BlitzMax. So I can't be sure I've set it right. It's rendering fine in Firefox and other areas of Windows for me. However, if you're using a bad font (or maybe pre-Windows 7 versions just don't render fonts even remotely correctly - Win7 still renders things in a pretty ugly way, though, so I don't know), then you probably won't see the character properly, not that this matters under Windows. |
| ||
Firefox should be rendering stuff in Times New Roman, which according to this page is not on the list of fonts that support that character: http://www.fileformat.info/info/unicode/char/2318/index.htm So did you change the default font firefox uses perhaps? |
| ||
You shouldn't be setting that character at all. It is set automatically by the system when you pass in the correct modifier. |
| ||
So did you change the default font firefox uses perhaps? Yes. Times New Roman and the other range of default fonts are pretty worn out and ugly. |
| ||
So, what font do you use then? :-) You shouldn't be setting that character at all. It is set automatically by the system when you pass in the correct modifier. Do you mean on just macs, or on Windows as well? I'm porting some code I wrote in BlitzPlus, so I don't know if BlitzMax behaves the same in this situation. I would assume I still have to add the Chr$(8)+ "Ctrl+S" thing on there even if I don't on the Mac... |
| ||
Wait a minute Brucey. That can't be right, because how would the Mac know which menu item to put the hotkey on? Here's how you create a menu item: Menu_Open = CreateMenu("Open...", 1, Menu_File) And here's how you create a hotkey: SetHotKeyEvent(KEY_O, MODIFIER_COMMAND) So how would the Mac link the two of those and figure out that the O key is for the Open menu item? |
| ||
Oh, damn... I see now. There's new parameters on the BlitzMax version of the function. That SetHotkeyEvent thing isn't even needed anymore. On another note... You know, for simplicity's sake, Blitzmax should really automatically translate MODIFER_CONTROL to the use the command button on the Mac, and MODIFIER_ALT to... the control button on the Mac I guess? Cause on the Mac you use COMMAND for anything you use CONTROL on the PC for. Would save me from using compiler directives to correct the issue. [edit] Oh... Damn again. :-) Please refer to the key codes module for valid key and modifier codes. The MODIFIER_COMMAND value should be used instead of MODIFIER_CONTROL with Menu hotkeys for best crossplatform compatability |
| ||
Blitzmax should really automatically translate MODIFER_CONTROL to the use the command button on the Mac, and MODIFIER_ALT to... the control button on the Mac I guess? It really shouldn't. Command, Control, and Option all have their specific uses. Treating Control as Command would result in a lot of very big portability issues. So, what font do you use then? :-) Palatino for serif and Gill Sans for sans-serif. Monotype is ProFont 10pt and Consolas 12pt under Mac OS and Windows respectively. |
| ||
Treating COMMAND as CONTROL is okay, but treating CONTROL as COMMAND would cause a lot of very big portability issues? :-) |
| ||
Who said Mac users treat Command as Control? Think of it this way, Control, Option, and Shift are modifiers and change behavior, Command is sort of a standard way of saying you want to invoke a command. You might apply Control, Option, and/or Shift to a Command key, and that would probably modify the default behavior of the command, but it would ideally be related to the default behavior somehow. |
| ||
Yes, but CONTROL on the PC serves that purpouse. Control is the standard way of saying you want to invoke a command. And on the PC, ALT and SHIFT, and the WINDOWS key are the modifiers. I think the way it translates is: COMMAND = CONTROL CONTROL = ALT OPTION = WINDOWS Having BlitzMax perform this translation automatically would not result in any portability issues. Having only COMMAND translate to CONTROL however, like Blitzmax does, does create portability issues. Because what happens when you're coding on a Mac and you specify you then want CONTROL to do something? When you compile on the PC, that will map to the same key that whatever you specified COMMAND should do. To rephrase things a bit, on a Mac, COMMAND-R and CONTROL-R are different keystrokes. But on a PC, they will be the same, because COMMAND maps to CONTROL. The only way around this is to either use constants to specify which keys go with which actions and wrap those in compile directives, or wrap your menu code in compiler directives and double it up. However, if BlitzMax did things the way I suggested, then as long as you wrote things out the way they'd be on a PC, they would end up in a configuration that makes sense on a Mac. You wouldn't lose access to any of the keys, and you wouldn't have conflicts arising when you compile on the opposing platform as outlined above. |
| ||
I'd reply and actually give you information, but the results of this COMMAND = CONTROL should prove to be absolutely hilarious, so I won't. CONTROL = ALT OPTION = WINDOWS |