小弟调调
小弟调调

Reputation: 1333

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/"]];
}

Upvotes: 0

Views: 74

Answers (1)

Caleb
Caleb

Reputation: 124997

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.

Upvotes: 1

Related Questions