简体   繁体   中英

cocoa:Why the event is not running?

NSLog(@"ss") execution.Why the event is not running ?

-(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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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