I've discovered that if I enter "option-command-D" as a keyboard
equivalent in ResEdit (!) for instance, it shows up as if I'm trying to
use the character "option-D" (a lower case delta, I think)...that's NOT
what I want...no user would recognize that. I was hoping that magically
that might show up as a "D" with the special "option" symbol in the
menu.
What is the proper way to add option-key or control-key keyboard
equivalents?
THANKS!
Well, the easiest way is to have your menus in a nib file and use
Interface Builder.
If you want to do it in code:
OSErr SetMenuItemModifiers (
MenuRef inMenu,
SInt16 inItem,
UInt8 inModifiers
);
enum {
kMenuNoModifiers = 0,
kMenuShiftModifier = (1 << 0),
kMenuOptionModifier = (1 << 1),
kMenuControlModifier = (1 << 2),
kMenuNoCommandModifier = (1 << 3)
};
> Well, the easiest way is to have your menus in a nib file and use
> Interface Builder.
>
> If you want to do it in code:
>
> OSErr SetMenuItemModifiers (
> MenuRef inMenu,
> SInt16 inItem,
> UInt8 inModifiers
> );
>
> enum {
> kMenuNoModifiers = 0,
> kMenuShiftModifier = (1 << 0),
> kMenuOptionModifier = (1 << 1),
> kMenuControlModifier = (1 << 2),
> kMenuNoCommandModifier = (1 << 3)
> };
Embarrassing to admit, but still using CW and ResEdit...so doing it via
code sounds pretty good at the moment. THANKS for the point in the
right direction...
Does this ONLY put the icon in the menu item but NOT actually modify
the menu processing? In other words, if I had a menu resource with,
say, a "D" as a keyboard equivalent, and I then, programmatically, used
"SetMenuItemModifiers" so that the user would see the "^" caret symbol
indicating the Control modifier key should be used with a
command-D"...it would display to the user that he or she should press
"command-control-D" but when I actually press that combination, my
command handler for that menu item is NOT called. It's as if that
SetMenuItemModifiers call JUST modified the look of the menu item not
the functioning of it? What am I missing (and thanks again for your
help)...
In article <uce-F83FFF.1...@comcast.dca.giganews.com>,
Gregory Weston <u...@splook.com> wrote:
The resource-based way to achieve this is with 'xmnu' resources. I believe
there was a ResEdit template with the Appearance Manager SDK way back when
(along with 'dlgx' templates and similar), which you could probably still find
somewhere on ftp.apple.com.
--
Jens Ayton
The reason why even though SetMenuItemModifiers correctly added
control-or-option-type keyboard equivalents to my menu but they didn't
appear to work is that elsewhere in my code I was using MenuKey()
instead of MenuEvent(). MenuKey is oblivious to the state of the
control, option and shift keys. I switched my code to use MenuEvent(),
and now it works like a charm.
Thanks Gregory and Jens for the much appreciated help!
In article <160720071637177382%j...@jkpoiaoq.com>, James
Just to be clear here... I hope you know that MenuEvent and the rest of the
classic Toolbox event system is officially "not recommended" and most
definitely should not be used for new development?
--
Jens Ayton
In article <Vfxni.4374$ZA....@newsb.telia.net>, Jens Ayton