From 5f49cb44b691375accce898d8a51fb2ecc61b40d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E4=B8=9C=E5=81=A5?= <1446723759@qq.com> Date: Thu, 12 Apr 2018 11:29:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8C=89=E9=92=AE=E6=9D=BE?= =?UTF-8?q?=E5=BC=80=E6=97=B6=E6=98=AF=E5=90=A6=E5=9C=A8=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E8=8C=83=E5=9B=B4=E5=86=85=E7=9A=84=E5=93=8D=E5=BA=94=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SYFlatButton/SYFlatButton/SYFlatButton.m | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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]; + } } }