Changeset 183 for trunk/ICeCoffEE/ICeCoffEE/ICeCoffEE.m
- Timestamp:
- 05/14/05 20:11:04 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ICeCoffEE/ICeCoffEE/ICeCoffEE.m
r182 r183 13 13 #import "ICeCoffEESuper.h" 14 14 #import "ICeCoffEESetServicesMenu.h" 15 #import "ICeCoffEETrigger.h" 15 16 16 17 iccfPrefRec ICCF_prefs; … … 59 60 } 60 61 61 iccfURLAction ICCF_KeyboardAction( ) {62 unsigned int modifierFlags = [ [NSApp currentEvent]modifierFlags];62 iccfURLAction ICCF_KeyboardAction(NSEvent *e) { 63 unsigned int modifierFlags = [e modifierFlags]; 63 64 iccfURLAction action; 64 65 action.presentMenu = (modifierFlags & NSAlternateKeyMask) != 0; … … 239 240 } 240 241 241 voidICCF_LaunchURL(NSString *string, iccfURLAction action) {242 OSStatus err ;242 BOOL ICCF_LaunchURL(NSString *string, iccfURLAction action) { 243 OSStatus err = noErr; 243 244 long selStart, selEnd; 244 245 unsigned len = [string length]; … … 273 274 NS_ENDHANDLER 274 275 275 DisposeHandle(h); 276 DisposeHandle(h); 277 278 return (err == noErr); 276 279 } 277 280 … … 303 306 } 304 307 305 void ICCF_LaunchURLFromTextView(NSTextView *self ) {308 void ICCF_LaunchURLFromTextView(NSTextView *self, NSEvent *triggeringEvent) { 306 309 NSCharacterSet *urlLeftDelimiters = nil, *urlRightDelimiters = nil; 307 310 NSRange range = [self selectedRange], delimiterRange; … … 371 374 [self display]; 372 375 373 ICCF_LaunchURL([s substringWithRange: range], ICCF_KeyboardAction()); 374 375 if (ICCF_prefs.textBlinkEnabled) { 376 if (ICCF_LaunchURL([s substringWithRange: range], ICCF_KeyboardAction(triggeringEvent)) && ICCF_prefs.textBlinkEnabled) { 376 377 for (i = 0 ; i < ICCF_prefs.textBlinkCount ; i++) { 377 378 NSRange emptyRange = {range.location, 0}; … … 500 501 } 501 502 503 static NSEvent *ICCF_MouseDownEventWithModifierFlags(NSEvent *e, BOOL inheritModifierFlags) { 504 return [NSEvent mouseEventWithType: NSLeftMouseDown 505 location: [e locationInWindow] 506 modifierFlags: (inheritModifierFlags ? [e modifierFlags] : 0) 507 timestamp: [e timestamp] 508 windowNumber: [e windowNumber] 509 context: [e context] 510 eventNumber: [e eventNumber] 511 clickCount: 1 512 pressure: 0]; 513 } 514 502 515 503 516 @interface NSTextView (IC_NSSharing) … … 526 539 servicesItem = nil; 527 540 } 528 [[NSApp servicesMenu] update]; // enable keyboard equivalents 541 if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_3) { 542 [[NSApp servicesMenu] update]; // enable keyboard equivalents in Mac OS X 10.3 543 } 529 544 } 530 545 … … 547 562 ICLog(@"ICeCoffEE down: %@", e); 548 563 #endif 564 if (ICCF_sharedTrigger != nil) { 565 ICLog(@"%@ cancelling", ICCF_sharedTrigger); 566 [ICCF_sharedTrigger cancel]; 567 } 549 568 if (ICCF_enabled && ICCF_prefs.commandClickEnabled && ICCF_EventIsCommandMouseDown(e)) { 569 BOOL inheritModifierFlags; 550 570 if ([self respondsToSelector: @selector(selectedRanges)]) { 551 // discontiguous selection support, Mac OS X 10.4 or later 552 NSArray *ranges = [self selectedRanges]; 553 ICLog(@"ICeCoffEE selected ranges: %@", ranges); 554 if ([ranges count] > 1 || [[ranges objectAtIndex: 0] rangeValue].length != 0) 555 goto bypass; 571 // Command-multiple-click or -drag for discontiguous selection, Mac OS X 10.4 or later 572 inheritModifierFlags = YES; 556 573 } else { 557 574 // don't want to trigger selection extension or anything else; pass through as a plain click 558 // (on Panther and earlier, command does not modify behavior) 575 // (on Mac OS X 10.3, command does not modify behavior) 576 inheritModifierFlags = NO; 559 577 } 560 [super mouseDown: [NSEvent mouseEventWithType: NSLeftMouseDown location: [e locationInWindow] modifierFlags: 0 timestamp: [e timestamp] windowNumber: [e windowNumber] context: [e context] eventNumber: [e eventNumber] clickCount: 1 pressure: 0]];578 [super mouseDown: ICCF_MouseDownEventWithModifierFlags(e, inheritModifierFlags)]; 561 579 // we don't actually get a mouseUp event, just wait for mouseDown to return 562 580 NSEvent *upEvent = [[self window] currentEvent]; … … 566 584 NSAssert([upEvent type] == NSLeftMouseUp, @"NSTextView mouseDown: did not return with current event as mouse up!"); 567 585 if (abs(downPt.x - upPt.x) <= kICHysteresisPixels && abs(downPt.y - upPt.y) <= kICHysteresisPixels) { 568 ICCF_LaunchURLFromTextView(self); 586 if (inheritModifierFlags) { 587 // Mac OS X 10.4 and later: make sure we don't have a command-double-click 588 [ICeCoffEETrigger setTriggerForEvent: e onTarget: self]; // gets stored in ICCF_sharedTrigger; the reason for this weird calling pattern is that we don't want to add methods to NSTextView, and we don't want to add a method call on every mouseDown 589 ICLog(@"%@ set", ICCF_sharedTrigger); 590 } else { 591 // Mac OS X 10.3 592 ICCF_LaunchURLFromTextView(self, e); 593 } 569 594 } 570 595 } else { 571 bypass:572 596 [super mouseDown: e]; 573 597 }
Note:
See TracChangeset
for help on using the changeset viewer.