Changeset 432


Ignore:
Timestamp:
03/03/08 08:59:32 (16 years ago)
Author:
Nicholas Riley
Message:

Fragile hack to determine whether we should draw the highlighted row as active.

Location:
trunk/ICeCoffEE/ICeCoffEE
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/ICeCoffEE/ICeCoffEE/ICeCoffEEInvertingTextFieldCell.m

    r428 r432  
    88
    99#import "ICeCoffEEInvertingTextFieldCell.h"
     10#import "ICeCoffEEMenuOutlineView.h"
    1011
    1112
     
    1920- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView;
    2021{
    21     if ([self isHighlighted] && [[controlView window] firstResponder] == controlView && [[controlView window] isKeyWindow]) {
     22    // XXX note cast to ICeCoffEEMenuOutlineView *; this is not general-purpose
     23    if ([self isHighlighted] && [(ICeCoffEEMenuOutlineView *)controlView shouldUseActiveHighlight]) {
    2224        NSMutableAttributedString *astr = [[self attributedStringValue] mutableCopy];
    2325        unsigned location = 0, length = [astr length];
  • trunk/ICeCoffEE/ICeCoffEE/ICeCoffEEMenuOutlineView.h

    r428 r432  
    1111
    1212@interface ICeCoffEEMenuOutlineView : NSOutlineView {
    13 
     13    NSWindow *mainWindow; // not retained
    1414}
    1515
     16- (BOOL)shouldUseActiveHighlight;
     17
    1618@end
  • trunk/ICeCoffEE/ICeCoffEE/ICeCoffEEMenuOutlineView.m

    r429 r432  
    1818}
    1919
     20// maintains main window (e.g., window to which sheet is attached) for use by shouldUseActiveHighlight
     21- (void)viewDidMoveToWindow;
     22{
     23    mainWindow = [NSApp mainWindow];
     24    [super viewDidMoveToWindow];
     25}
     26
     27- (BOOL)shouldUseActiveHighlight;
     28{
     29    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;
     40}
     41
    2042- (void)highlightSelectionInClipRect:(NSRect)clipRect;
    2143{
     
    2446
    2547    HIThemeMenuItemDrawInfo drawInfo = {0, kThemeMenuItemHierBackground | kThemeMenuItemPopUpBackground, kThemeMenuSelected};
    26     if ([[self window] firstResponder] != self || [NSApp keyWindow] != [self window]) {
    27         NSLog(@"firstResponder %@ key %@ main %@ this %@", [[self window] firstResponder], [NSApp keyWindow], [NSApp mainWindow], [self window]);
     48    NSLog(@"firstResponder %@ key %@ isKey %d main %@", [[self window] firstResponder], [NSApp keyWindow], [[self window] isKeyWindow], [NSApp mainWindow]);
     49    if (![self shouldUseActiveHighlight]) {
     50        instrumentObjcMessageSends(YES);
    2851        [super highlightSelectionInClipRect: clipRect];
     52        instrumentObjcMessageSends(NO);
    2953        return;
    3054    }
  • trunk/ICeCoffEE/ICeCoffEE/ICeCoffEEServicePrefController.m

    r431 r432  
    1010#import "ICeCoffEEServices.h"
    1111#import "ICeCoffEEServicePrefController.h"
     12#import "ICeCoffEEMenuOutlineView.h"
    1213#import "ICeCoffEENonHighlightingButtonCell.h"
    1314#import "ICeCoffEEInvertingTextFieldCell.h"
     
    477478   
    478479    if (![outlineView isRowSelected: [outlineView rowForItem: item]] ||
    479         [[outlineView window] firstResponder] != outlineView || ![[outlineView window] isKeyWindow]) {
     480        ![(ICeCoffEEMenuOutlineView *)outlineView shouldUseActiveHighlight]) {
    480481        if (!isInverted)
    481482            return;
Note: See TracChangeset for help on using the changeset viewer.