Changeset 433 for trunk/ICeCoffEE/ICeCoffEE/ICeCoffEEMenuOutlineView.m
- Timestamp:
- 03/03/08 09:25:06 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ICeCoffEE/ICeCoffEE/ICeCoffEEMenuOutlineView.m
r432 r433 10 10 #import <Carbon/Carbon.h> 11 11 12 // Tiger or later, indicates whether highlighted row should draw as active 13 @interface NSWindow (IC_KeyboardFocus) 14 - (BOOL)_isKeyWindowIgnoringFocus; 15 @end 16 17 BOOL ICCF_ViewHasKeyboardFocus(NSView *view) { 18 NSWindow *window = [view window]; 19 if ([window firstResponder] != view) 20 return NO; 21 22 if ([window respondsToSelector: @selector(_isKeyWindowIgnoringFocus)]) 23 return [window _isKeyWindowIgnoringFocus]; 24 25 // XXX is there a documented way to do this? 26 // see <http://lists.apple.com/archives/cocoa-dev/2008/Mar/msg00036.html> 27 28 // test cases: 29 // - About System Preferences... 30 // - focused character palette 31 // - Help menu search (Shortcut) 32 // - menu extras 33 NSWindow *keyWindow = [NSApp keyWindow]; 34 if (window != keyWindow && (keyWindow == nil || [keyWindow isKindOfClass: [NSPanel class]])) 35 return NO; // exclude NSCarbonMenuWindow 36 37 return YES; 38 } 39 12 40 @implementation ICeCoffEEMenuOutlineView 13 41 … … 18 46 } 19 47 20 // maintains main window (e.g., window to which sheet is attached) for use by shouldUseActiveHighlight21 - (void)viewDidMoveToWindow;22 {23 mainWindow = [NSApp mainWindow];24 [super viewDidMoveToWindow];25 }26 27 48 - (BOOL)shouldUseActiveHighlight; 28 49 { 29 50 return NO; 30 // test cases: - XXX there should be a better way to do this 31 // see <http://lists.apple.com/archives/cocoa-dev/2008/Mar/msg00036.html> 32 // - About System Preferences... 33 // - focused character palette 34 // - Help menu search (Shortcut) 35 // - menu extras 36 NSWindow *keyWindow = [NSApp keyWindow], *thisWindow = [self window]; 37 if (keyWindow != thisWindow && [keyWindow isKindOfClass: [NSPanel class]]) 38 return NO; // exclude NSCarbonMenuWindow 39 return [thisWindow firstResponder] == self && [NSApp mainWindow] == mainWindow; 51 return [[self window] _isKeyWindowIgnoringFocus]; 40 52 } 41 53 … … 46 58 47 59 HIThemeMenuItemDrawInfo drawInfo = {0, kThemeMenuItemHierBackground | kThemeMenuItemPopUpBackground, kThemeMenuSelected}; 48 NSLog(@"firstResponder %@ key %@ isKey %d main %@", [[self window] firstResponder], [NSApp keyWindow], [[self window] isKeyWindow], [NSApp mainWindow]); 49 if (![self shouldUseActiveHighlight]) { 50 instrumentObjcMessageSends(YES); 60 if (!ICCF_ViewHasKeyboardFocus(self)) { 51 61 [super highlightSelectionInClipRect: clipRect]; 52 instrumentObjcMessageSends(NO);53 62 return; 54 63 }
Note:
See TracChangeset
for help on using the changeset viewer.