Re: NSMenuItem setKeyEquivalentModifierMask not working as expected
Re: NSMenuItem setKeyEquivalentModifierMask not working as expected
- Subject: Re: NSMenuItem setKeyEquivalentModifierMask not working as expected
- From: David Kocher <email@hidden>
- Date: Sun, 30 Jan 2005 14:53:00 +0100
That solves the problem. Many thanks!
Btw: Sometimes I am wondering about the API design; i.e. it would make
more sense if it would be
setKeyEquivalent(char)
instead of
setKeyEquivalent(String)
and the problem I have described should result in a wrong key
equivalent assigned but not influence the modifier key, should it?!
Anyway; thanks for the quick resolution of the problem.
-dk
On 30. Jan 2005, at 14:36, j o a r wrote:
What happens if you assign "f" instead of "F"?
j o a r
On 2005-01-30, at 14.03, David Kocher wrote:
Trying to assign a key equivalent to a menu item in a NSPopupButton
doesn't seem to work; or at least not as I expect to work. Although I
assign a modifier mask of NSEvent.CommandKeyMask; the menu items
always have both the shift and command key modifier assigned.
This code
public void setProtocolPopup(NSPopUpButton protocolPopup) {
this.protocolPopup = protocolPopup;
this.protocolPopup.removeAllItems();
this.protocolPopup.addItemsWithTitles(new NSArray(new String[]
{FTP_STRING, SFTP_STRING}));
this.protocolPopup.itemWithTitle(FTP_STRING).setKeyEquivalentModifierM
ask(NSEvent.CommandKeyMask);
this.protocolPopup.itemWithTitle(FTP_STRING).setKeyEquivalent("F");
this.protocolPopup.itemWithTitle(SFTP_STRING).setKeyEquivalentModifier
Mask(NSEvent.CommandKeyMask);
this.protocolPopup.itemWithTitle(SFTP_STRING).setKeyEquivalent("S");
this.protocolPopup.setTarget(this);
this.protocolPopup.setAction(new
NSSelector("protocolSelectionDidChange", new Class[]{Object.class}));
}
will result in a popup button with the key equivalents
<shift><command>F
<shift><command>S
Thanks for any hints!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden