开发者

NSButton key equivalent

I can't make a key equivalent work on an NSButton that I have created programatically. Can anyone advise me of what I'm doing wrong? The button works as intended when pressed, but the key equivalent will not work.

NSButton *ESCButton = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 10, 10)];
[[quickEntryWindow contentView] addSubview:ESCButton];
[[ESCButton cell] setKeyEquivalent:@"\E"];
[ESCButton setTarget:self];
//[ESCButton setTransparent:YES];
[ESCButton setAction:@selector(hideQuickEntryWindow)];开发者_如何学Go
[quickEntryWindow setDefaultButtonCell:[ESCButton cell]];
[quickEntryWindow enableKeyEquivalentForDefaultButtonCell];


-setDefaultButtonCell: turns the cell into the window default button cell, which necessarily has key equivalent \r (Return/Enter). If you want to use another key equivalent, remove

[quickEntryWindow setDefaultButtonCell:[ESCButton cell]];
[quickEntryWindow enableKeyEquivalentForDefaultButtonCell];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜