Changeset 442 for trunk/ICeCoffEE


Ignore:
Timestamp:
03/06/08 11:36:32 (17 years ago)
Author:
Nicholas Riley
Message:

Move index-to-range conversion into a class method for launch methods that do not use a trigger

Location:
trunk/ICeCoffEE/ICeCoffEE
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ICeCoffEE/ICeCoffEE/ICeCoffEETrigger.h

    r388 r442  
    1919+ (BOOL)cancel;
    2020
     21+ (NSRange)rangeForEvent:(NSEvent *)anEvent onTarget:(NSView <NSTextInput> *)aTarget;
     22
    2123- (void)timerFired:(NSTimer *)aTimer; // overridden by subclasses
    2224
  • trunk/ICeCoffEE/ICeCoffEE/ICeCoffEETrigger.m

    r390 r442  
    1515@implementation ICeCoffEETrigger
    1616
     17+ (NSRange)rangeForEvent:(NSEvent *)anEvent onTarget:(NSView<NSTextInput> *)aTarget;
     18{
     19    unsigned characterIndex = [aTarget characterIndexForPoint:
     20                               [[aTarget window] convertBaseToScreen: [anEvent locationInWindow]]];
     21    NSRange range = [aTarget selectedRange];
     22    ICLog(@"ICeCoffEETrigger characterIndex %u selectedRange %@", characterIndex, NSStringFromRange(range));
     23    if (range.location == NSNotFound || range.length == 0 ||
     24        !NSLocationInRange(characterIndex, range)) {
     25        range.location = characterIndex;
     26        range.length = 0;
     27    }
     28    return range;
     29}
     30
    1731- (id)initForEvent:(NSEvent *)anEvent onTarget:(NSView<NSTextInput> *)aTarget;
    1832{
     
    2034        target = [aTarget retain];
    2135        event = [anEvent retain];
    22         unsigned characterIndex = [aTarget characterIndexForPoint:
    23                                    [[aTarget window] convertBaseToScreen: [anEvent locationInWindow]]];
    24         range = [aTarget selectedRange];
    25         ICLog(@"ICeCoffEETrigger characterIndex %u selectedRange %@", characterIndex, NSStringFromRange(range));
    26         if (range.location == NSNotFound || range.length == 0 ||
    27             !NSLocationInRange(characterIndex, range)) {
    28             range.location = characterIndex;
    29             range.length = 0;
    30         }
     36        range = [[self class] rangeForEvent: anEvent onTarget: aTarget];
    3137        // no typical definition of Command-Option-double-click, so we don't need to delay
    3238        NSTimeInterval interval = ([anEvent modifierFlags] & NSAlternateKeyMask) ? 0 :
Note: See TracChangeset for help on using the changeset viewer.