Skip to content

Commit

Permalink
use NSEvent.doubleClickInterval if available
Browse files Browse the repository at this point in the history
  • Loading branch information
psychs committed Jun 23, 2010
1 parent ba726b8 commit 6f8041c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Classes/Views/Log/LogScriptEventSink.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

#define DOUBLE_CLICK_RADIUS 3

@interface NSEvent (SnowLeopardCompatibility)
+ (NSTimeInterval)doubleClickInterval;
@end


@implementation LogScriptEventSink

Expand Down Expand Up @@ -76,12 +80,18 @@ - (BOOL)shouldStopDoubleClick:(id)e

BOOL res = NO;

CFAbsoluteTime now = CFAbsoluteTimeGetCurrent();
float doubleClickThreshold = GetDblTime() / 60.0;
CFAbsoluteTime doubleClickThreshold = 0;
if ([NSEvent respondsToSelector:@selector(doubleClickInterval)]) {
doubleClickThreshold = [NSEvent doubleClickInterval];
}
else {
doubleClickThreshold = GetDblTime() / 60.0;
}
if (doubleClickThreshold == 0) {
doubleClickThreshold = 0.5;
}

CFAbsoluteTime now = CFAbsoluteTimeGetCurrent();
if (x-d <= cx && cx <= x+d && y-d <= cy && cy <= y+d) {
if (now < lastClickTime + doubleClickThreshold) {
res = YES;
Expand Down

0 comments on commit 6f8041c

Please sign in to comment.