Changeset 355 for trunk/Cocoa/Pester/Source/NJRFSObjectSelector.m
- Timestamp:
- 11/23/07 04:58:05 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/Pester/Source/NJRFSObjectSelector.m
r53 r355 1 1 #import "NJRFSObjectSelector.h" 2 #import "NSMenuItem-NJRExtensions.h" 2 3 #import "NSImage-NJRExtensions.h" 3 4 #import "NSString-NJRExtensions.h" … … 84 85 - (void)setImage:(NSImage *)image; 85 86 { 87 // XXX change to use IconRef; see ICeCoffEELabeledIconCell and Google 86 88 [super setImage: [image bestFitImageForSize: [[self cell] cellSize]]]; 87 89 } … … 111 113 NSAssert1([files count] == 1, @"%d items returned, only one expected", [files count]); 112 114 [self setPath: [files objectAtIndex: 0]]; 113 [[self target] tryToPerform: [self action] with: self]; 115 if ([self target] != nil && [[self target] respondsToSelector:[self action]]) 116 [[self target] performSelector: [self action] withObject: self]; 114 117 } 115 118 } … … 145 148 } 146 149 do { 150 NSAssert1(![path isEqualToString: revealPath], @"Stuck on path |%@|", [alias fullPath]); 147 151 item = [menu addItemWithTitle: [fmgr displayNameAtPath: path] 148 152 action: @selector(revealInFinder:) … … 150 154 [item setTarget: self]; 151 155 [item setRepresentedObject: revealPath]; 152 [item setImage: 153 [[[NSWorkspace sharedWorkspace] iconForFile: path] bestFitImageForSize: NSMakeSize(16, 16)]]; 156 [item setImageFromPath: path]; 154 157 revealPath = path; 155 158 path = [path stringByDeletingLastPathComponent]; 156 NSAssert1(![path isEqualToString: revealPath], @"Stuck on path |%@|", [alias fullPath]);157 159 } while (![revealPath isEqualToString: @"/"] && ![path isEqualToString: @"/Volumes"]); 158 160 [[self cell] setMenu: menu]; … … 195 197 - (void)mouseDown:(NSEvent *)theEvent; 196 198 { 199 if (![self isEnabled]) return; 200 197 201 NSMenu *menu = [[self cell] menu]; 198 202 MenuRef mRef = _NSGetCarbonMenu(menu); … … 219 223 pressure: [theEvent pressure]]; 220 224 221 // this undocumented API does not work any better; contextual menu items are still added: 222 // [menu _popUpMenuWithEvent: theEvent forView: self]; 223 [NSMenu popUpContextMenu: menu withEvent: theEvent forView: self]; 225 // XXX otherwise Cocoa thoughtfully doesn't give me the font I want 226 NSFont *font = [[self cell] font]; 227 [NSMenu popUpContextMenu: menu withEvent: theEvent forView: self withFont: 228 [NSFont fontWithName: [font fontName] size: [font pointSize] - 0.001]]; 224 229 } 225 230 … … 310 315 if (url == nil) return NO; 311 316 [self setPath: [url path]]; 312 [[self target] tryToPerform: [self action] with: self]; 317 if ([self target] != nil && [[self target] respondsToSelector:[self action]]) 318 [[self target] performSelector: [self action] withObject: self]; 313 319 } 314 320 return YES;
Note:
See TracChangeset
for help on using the changeset viewer.