简体   繁体   English

可可:为什么事件未运行?

[英]cocoa:Why the event is not running?

NSLog(@"ss") execution.Why the event is not running ? NSLog(@"ss")执行。为什么事件未运行?

-(void)mouseUp:(NSEvent *)theEvent{
    switch (self.tag) {
        case 3:
            NSLog(@"ss");
            [self setAction:@selector(openurl:)];
            break;
        default:
            break;
    }
}

- (IBAction)openurl:(id)sender {
    [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.google.com/"]];
}

Your code is setting the action, but not sending it. 您的代码正在设置操作,但未发送。 Setting the action just tells the control what action to send when something happens. 设置动作只是告诉控件什么情况下要发送什么动作。 And since you seem to also be overriding -mouseUp: , the control's normal event processing for mouse ups won't happen and the action may never be sent. 而且,由于您似乎也要覆盖-mouseUp:因此不会发生控件对鼠标-mouseUp:的正常事件处理,并且可能永远不会发送该操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM