0

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/"]];
}
小弟调调
  • 1,315
  • 1
  • 17
  • 33

1 Answers1

1

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.

Caleb
  • 124,013
  • 19
  • 183
  • 272
  • Can not be set in the mouseUp inside the event? – 小弟调调 Apr 30 '12 at 11:18
  • How do I do ? `[button setAction:@selector(openWeibo:)];`Nor is the implementation . – 小弟调调 Apr 30 '12 at 11:26
  • Normally you shouldn't need to set the action for a control inside an event handler. If you're using a .xib, set it there. If you're creating the control programmatically, set the action for the control when you create the control. – Caleb Apr 30 '12 at 12:25