- Timestamp:
- 03/03/08 09:25:06 (17 years ago)
- Location:
- trunk/ICeCoffEE/ICeCoffEE
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ICeCoffEE/ICeCoffEE/ICeCoffEEInvertingTextFieldCell.m
r432 r433 20 20 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView; 21 21 { 22 // XXX note cast to ICeCoffEEMenuOutlineView *; this is not general-purpose 23 if ([self isHighlighted] && [(ICeCoffEEMenuOutlineView *)controlView shouldUseActiveHighlight]) { 22 if ([self isHighlighted] && ICCF_ViewHasKeyboardFocus(controlView)) { 24 23 NSMutableAttributedString *astr = [[self attributedStringValue] mutableCopy]; 25 24 unsigned location = 0, length = [astr length]; -
trunk/ICeCoffEE/ICeCoffEE/ICeCoffEEMenuOutlineView.h
r432 r433 9 9 #import <Cocoa/Cocoa.h> 10 10 11 BOOL ICCF_ViewHasKeyboardFocus(NSView *view); 11 12 12 13 @interface ICeCoffEEMenuOutlineView : NSOutlineView { 13 NSWindow *mainWindow; // not retained 14 14 15 } 15 16 16 - (BOOL)shouldUseActiveHighlight;17 18 17 @end -
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 } -
trunk/ICeCoffEE/ICeCoffEE/ICeCoffEEServicePrefController.m
r432 r433 478 478 479 479 if (![outlineView isRowSelected: [outlineView rowForItem: item]] || 480 ! [(ICeCoffEEMenuOutlineView *)outlineView shouldUseActiveHighlight]) {480 !ICCF_ViewHasKeyboardFocus(outlineView)) { 481 481 if (!isInverted) 482 482 return;
Note:
See TracChangeset
for help on using the changeset viewer.