开发者

NSButton key equivalent

开发者 https://www.devze.com 2023-02-11 19:37 出处:网络
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

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

精彩评论

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