FROM : Bill Monk
DATE : Sat Jul 15 20:20:09 2006
On Jul 14, 2006, at 8:34 PM, Shoaib Hannani wrote:
> In Safari and Mail, there are shortcuts to make text bigger (Command
> +) and smaller (Command -) that work whether the SHIFT key is pressed
> down or not.
>
> In the case of making text bigger (Command +) which requires you to
> press the SHIFT key, Safari and Mail don't require it so you're
> essentially pressing "Command =" but the shortcut in the menu says
> "Command +".
>
> Does anyone know how I can achieve the same effect?
Carbon SetMenuItemCommandKey() can assign both a user-visible command
key (what the user thinks they are typing) and a "virtual" key (what
is actually typed).
A slight problem is getting a Carbon MenuRef from a Cocoa NSMenu.
Undocumented Goodness <http://www.cocoadev.com/index.pl?NSMenu>
mentions _NSGetCarbonMenu(NSMenu* aMenu), but I've never managed to
make that work....
Anyway, assuming a MenuRef to, say, the Help menu, Carbon set the
display keycode to Cmd-? and the virtual keycode to Cmd-/ , so it
doesn't matter if Shift is down or not.
MenuRef helpMenuRef; // getting this is left as an exercise for the
reader :) ...
// make Cmd-? work without having to hold down shift key
SetMenuItemCommandKey( helpMenuRef, 1, false, '?');
SetMenuItemCommandKey( helpMenuRef, 1, true, 0x2C ); // set virtual
key to '/', i.e Cmd-slash
DATE : Sat Jul 15 20:20:09 2006
On Jul 14, 2006, at 8:34 PM, Shoaib Hannani wrote:
> In Safari and Mail, there are shortcuts to make text bigger (Command
> +) and smaller (Command -) that work whether the SHIFT key is pressed
> down or not.
>
> In the case of making text bigger (Command +) which requires you to
> press the SHIFT key, Safari and Mail don't require it so you're
> essentially pressing "Command =" but the shortcut in the menu says
> "Command +".
>
> Does anyone know how I can achieve the same effect?
Carbon SetMenuItemCommandKey() can assign both a user-visible command
key (what the user thinks they are typing) and a "virtual" key (what
is actually typed).
A slight problem is getting a Carbon MenuRef from a Cocoa NSMenu.
Undocumented Goodness <http://www.cocoadev.com/index.pl?NSMenu>
mentions _NSGetCarbonMenu(NSMenu* aMenu), but I've never managed to
make that work....
Anyway, assuming a MenuRef to, say, the Help menu, Carbon set the
display keycode to Cmd-? and the virtual keycode to Cmd-/ , so it
doesn't matter if Shift is down or not.
MenuRef helpMenuRef; // getting this is left as an exercise for the
reader :) ...
// make Cmd-? work without having to hold down shift key
SetMenuItemCommandKey( helpMenuRef, 1, false, '?');
SetMenuItemCommandKey( helpMenuRef, 1, true, 0x2C ); // set virtual
key to '/', i.e Cmd-slash
| Related mails | Author | Date |
|---|---|---|
| Shoaib Hannani | Jul 14, 21:59 | |
| Michael Watson | Jul 14, 22:44 | |
| I. Savant | Jul 14, 22:54 | |
| Justin Anderson | Jul 15, 14:57 | |
| Bill Monk | Jul 15, 20:20 |






Cocoa mail archive

