按下按钮时如何制作NSWindow弹出窗口

时间:2015-02-06 21:10:31

标签: cocoa nswindow nsbutton

我的可可程序中有一个小的itty bitty帮助按钮。我想知道如何制作它,在按下时,制作一个小的nswindow面板弹出窗口,上面有很多文字。我怎样才能做到这一点?该按钮名为help,窗口可以称为helpwin

2 个答案:

答案 0 :(得分:1)

我明白了。我所要做的就是为我的面板创建@property。然后在我的按钮IBAction中,我写了

- (IBAction)help:(id)sender {
    if (![self.helpWin isVisible]) {
        [self.helpWin makeKeyAndOrderFront:sender];
    }
}

它有效!

答案 1 :(得分:1)

根据您的面板需要的复杂程度,您可以简单地弹出一个NSRunAlertPanel。

-(IB Action)helpPanel:(id)sender
{
    NSInteger choice = NSRunAlertPanel(@"Help", @"The previous string is the titel or main message of your alert panel. This is theft can be longer. You then have three buttons to fill in, the default button and two alternate buttons. With the alternate buttons on 'nil', you get only one button.", @"ok", nil, nil);
}