diff --git a/SYFlatButton/SYFlatButton/SYFlatButton.m b/SYFlatButton/SYFlatButton/SYFlatButton.m index 8e589cb..d219db6 100644 --- a/SYFlatButton/SYFlatButton/SYFlatButton.m +++ b/SYFlatButton/SYFlatButton/SYFlatButton.m @@ -264,7 +264,12 @@ - (void)mouseUp:(NSEvent *)event { if (self.momentary) { self.state = (self.state == NSOnState) ? NSOffState : NSOnState; } - [NSApp sendAction:self.action to:self.target from:self]; + NSPoint eventLocation = [event locationInWindow]; + NSPoint point = [self convertPoint:eventLocation fromView:nil]; + if (NSPointInRect(point, self.bounds)) { + //松开位置在按钮范围内 + [NSApp sendAction:self.action to:self.target from:self]; + } } }