自定义NSTextFieldCell中的NSButton

时间:2014-04-01 09:33:53

标签: cocoa nsbutton nstextfieldcell

我只想在自定义的NStextFieldCell中添加带有setAction的简单NSButton ... 但我的处理器占用了100%......

我的自定义NStextFieldCell类中的代码如下:

- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
...
NSButton *myButton = [[NSButton alloc] initWithFrame:NSMakeRect(cellFrame.origin.x+200, cellFrame.origin.y+5, 30, 30)];
[controlView addSubview: myButton];
[myButton setTitle: @"Button title!"];
[myButton setButtonType:NSMomentaryLightButton]; 
[myButton setBezelStyle:NSRoundedBezelStyle]; 
[myButton setTarget:self];
[myButton setAction:@selector(myAction)];

...
}

任何想法? 感谢

0 个答案:

没有答案