Revision: 2835
          http://skim-app.svn.sourceforge.net/skim-app/?rev=2835&view=rev
Author:   hofman
Date:     2007-09-05 09:11:40 -0700 (Wed, 05 Sep 2007)

Log Message:
-----------
Check the view for type-select for first responder status and for the field 
editor.

Modified Paths:
--------------
    trunk/SKOutlineView.m
    trunk/SKPDFView.m
    trunk/SKTableView.m
    trunk/SKTypeSelectHelper.h
    trunk/SKTypeSelectHelper.m

Modified: trunk/SKOutlineView.m
===================================================================
--- trunk/SKOutlineView.m       2007-09-05 13:52:22 UTC (rev 2834)
+++ trunk/SKOutlineView.m       2007-09-05 16:11:40 UTC (rev 2835)
@@ -91,9 +91,9 @@
     unichar eventChar = [characters length] > 0 ? [characters 
characterAtIndex:0] : 0;
        unsigned modifierFlags = [theEvent modifierFlags] & 
NSDeviceIndependentModifierFlagsMask;
     
-    if ([typeSelectHelper isTypeSelectEvent:theEvent])
-        [typeSelectHelper processKeyDownEvent:theEvent];
-    else if ([typeSelectHelper isRepeatEvent:theEvent])
+    if ([typeSelectHelper isTypeSelectEvent:theEvent forView:self])
+        [typeSelectHelper processKeyDownEvent:theEvent forView:self];
+    else if ([typeSelectHelper isRepeatEvent:theEvent forView:self])
         [typeSelectHelper repeatSearch];
     else if (eventChar == NSHomeFunctionKey && (modifierFlags & 
~NSFunctionKeyMask) == 0)
         [self scrollToBeginningOfDocument:nil];

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2007-09-05 13:52:22 UTC (rev 2834)
+++ trunk/SKPDFView.m   2007-09-05 16:11:40 UTC (rev 2835)
@@ -952,9 +952,9 @@
             [self setAnnotationMode:SKStrikeOutNote];
         } else if ([self toolMode] == SKNoteToolMode && modifiers == 0 && 
eventChar == 'l') {
             [self setAnnotationMode:SKLineNote];
-        } else if ([typeSelectHelper isTypeSelectEvent:theEvent]) {
-            [typeSelectHelper processKeyDownEvent:theEvent];
-        } else if ([typeSelectHelper isRepeatEvent:theEvent]) {
+        } else if ([typeSelectHelper isTypeSelectEvent:theEvent forView:self]) 
{
+            [typeSelectHelper processKeyDownEvent:theEvent forView:self];
+        } else if ([typeSelectHelper isRepeatEvent:theEvent forView:self]) {
             [typeSelectHelper repeatSearch];
         } else {
             [super keyDown:theEvent];

Modified: trunk/SKTableView.m
===================================================================
--- trunk/SKTableView.m 2007-09-05 13:52:22 UTC (rev 2834)
+++ trunk/SKTableView.m 2007-09-05 16:11:40 UTC (rev 2835)
@@ -69,9 +69,9 @@
     unichar eventChar = [characters length] > 0 ? [characters 
characterAtIndex:0] : 0;
        unsigned modifierFlags = [theEvent modifierFlags] & 
NSDeviceIndependentModifierFlagsMask;
     
-    if ([typeSelectHelper isTypeSelectEvent:theEvent])
-        [typeSelectHelper processKeyDownEvent:theEvent];
-    else if ([typeSelectHelper isRepeatEvent:theEvent])
+    if ([typeSelectHelper isTypeSelectEvent:theEvent forView:self])
+        [typeSelectHelper processKeyDownEvent:theEvent forView:self];
+    else if ([typeSelectHelper isRepeatEvent:theEvent forView:self])
         [typeSelectHelper repeatSearch];
        else if ((eventChar == NSDeleteCharacter || eventChar == 
NSDeleteFunctionKey) && modifierFlags == 0 && [self canDelete])
         [self delete:self];

Modified: trunk/SKTypeSelectHelper.h
===================================================================
--- trunk/SKTypeSelectHelper.h  2007-09-05 13:52:22 UTC (rev 2834)
+++ trunk/SKTypeSelectHelper.h  2007-09-05 16:11:40 UTC (rev 2835)
@@ -76,12 +76,12 @@
 
 - (void)rebuildTypeSelectSearchCache;
 
-- (void)processKeyDownEvent:(NSEvent *)keyEvent;
+- (void)processKeyDownEvent:(NSEvent *)keyEvent forView:(NSView *)view;
 - (void)repeatSearch;
 - (void)stopSearch;
 
-- (BOOL)isTypeSelectEvent:(NSEvent *)keyEvent;
-- (BOOL)isRepeatEvent:(NSEvent *)keyEvent;
+- (BOOL)isTypeSelectEvent:(NSEvent *)keyEvent forView:(NSView *)view;
+- (BOOL)isRepeatEvent:(NSEvent *)keyEvent forView:(NSView *)view;
 
 @end
 

Modified: trunk/SKTypeSelectHelper.m
===================================================================
--- trunk/SKTypeSelectHelper.m  2007-09-05 13:52:22 UTC (rev 2834)
+++ trunk/SKTypeSelectHelper.m  2007-09-05 16:11:40 UTC (rev 2835)
@@ -139,26 +139,28 @@
     searchCache = [[dataSource typeSelectHelperSelectionItems:self] retain];
 }
 
-- (void)processKeyDownEvent:(NSEvent *)keyEvent {
-    NSText *fieldEditor = [[NSApp keyWindow] fieldEditor:YES forObject:self];
-    
-    if (processing == NO)
-        [fieldEditor setString:@""];
-    
-    // Append the new character to the search string
-    [fieldEditor interpretKeyEvents:[NSArray arrayWithObject:keyEvent]];
-    [self setSearchString:[fieldEditor string]];
-    
-    if ([dataSource 
respondsToSelector:@selector(typeSelectHelper:updateSearchString:)])
-        [dataSource typeSelectHelper:self updateSearchString:searchString];
-    
-    // Reset the timer if it hasn't expired yet
-    [self startTimerForSelector:@selector(typeSelectSearchTimeout:)];
-    
-    if (matchesImmediately)
-        [self searchWithStickyMatch:processing];
-    
-    processing = YES;
+- (void)processKeyDownEvent:(NSEvent *)keyEvent forView:(NSView *)view {
+    if ([self isTypeSelectEvent:keyEvent forView:view]) {
+        NSText *fieldEditor = [[view window] fieldEditor:YES forObject:self];
+        
+        if (processing == NO)
+            [fieldEditor setString:@""];
+        
+        // Append the new character to the search string
+        [fieldEditor interpretKeyEvents:[NSArray arrayWithObject:keyEvent]];
+        [self setSearchString:[fieldEditor string]];
+        
+        if ([dataSource 
respondsToSelector:@selector(typeSelectHelper:updateSearchString:)])
+            [dataSource typeSelectHelper:self updateSearchString:searchString];
+        
+        // Reset the timer if it hasn't expired yet
+        [self startTimerForSelector:@selector(typeSelectSearchTimeout:)];
+        
+        if (matchesImmediately)
+            [self searchWithStickyMatch:processing];
+        
+        processing = YES;
+    }
 }
 
 - (void)repeatSearch {
@@ -177,11 +179,13 @@
         [self typeSelectCleanTimeout:timer];
 }
 
-- (BOOL)isTypeSelectEvent:(NSEvent *)keyEvent {
+- (BOOL)isTypeSelectEvent:(NSEvent *)keyEvent forView:(NSView *)view {
     if ([keyEvent type] != NSKeyDown)
         return NO;
     if ([keyEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask & 
~NSShiftKeyMask & ~NSAlternateKeyMask)
         return NO;
+    if ([[view window] firstResponder] != view)
+        return NO;
     
     NSString *characters = [keyEvent charactersIgnoringModifiers];
     int i, count = [characters length];
@@ -200,9 +204,11 @@
     return YES;
 }
 
-- (BOOL)isRepeatEvent:(NSEvent *)keyEvent {
+- (BOOL)isRepeatEvent:(NSEvent *)keyEvent forView:(NSView *)view {
     if ([keyEvent type] != NSKeyDown)
         return NO;
+    if ([[view window] firstResponder] != view)
+        return NO;
     
     NSString *characters = [keyEvent charactersIgnoringModifiers];
     unichar character = [characters length] > 0 ? [characters 
characterAtIndex:0] : 0;


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to