Add context menu to file table

This commit is contained in:
Mitchell Livingston
2006-06-16 00:04:29 +00:00
parent d7388093b6
commit efb73e8b5b
6 changed files with 33 additions and 9 deletions

View File

@@ -1,6 +1,11 @@
{
IBClasses = (
{CLASS = FileTableView; LANGUAGE = ObjC; SUPERCLASS = NSTableView; },
{
CLASS = FileTableView;
LANGUAGE = ObjC;
OUTLETS = {fContextMenu = NSMenu; };
SUPERCLASS = NSTableView;
},
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{
ACTIONS = {revealFile = id; setRatioCheck = id; setRatioLimit = id; };

View File

@@ -3,7 +3,12 @@
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>94 65 356 240 0 0 1440 878 </string>
<string>69 61 356 240 0 0 1152 842 </string>
<key>IBEditorPositions</key>
<dict>
<key>549</key>
<string>69 306 75 68 0 0 1152 842 </string>
</dict>
<key>IBFramework Version</key>
<string>446.1</string>
<key>IBLockedObjects</key>
@@ -16,9 +21,10 @@
</array>
<key>IBOpenObjects</key>
<array>
<integer>549</integer>
<integer>5</integer>
</array>
<key>IBSystem Version</key>
<string>8I1119</string>
<string>8I127</string>
</dict>
</plist>

View File

@@ -26,6 +26,7 @@
@interface FileTableView : NSTableView
{
IBOutlet NSMenu * fContextMenu;
}
@end

View File

@@ -32,4 +32,20 @@
[super mouseDown: event];
}
- (NSMenu *) menuForEvent: (NSEvent *) e
{
int row = [self rowAtPoint: [self convertPoint: [e locationInWindow] fromView: nil]];
if (row >= 0)
{
if (![self isRowSelected: row])
[self selectRowIndexes: [NSIndexSet indexSetWithIndex: row]
byExtendingSelection: NO];
}
else
[self deselectAll: self];
return fContextMenu;
}
@end

View File

@@ -115,13 +115,9 @@
- (NSMenu *) menuForEvent: (NSEvent *) e
{
NSPoint point;
int row;
point = [self convertPoint: [e locationInWindow] fromView: nil];
row = [self rowAtPoint: point];
int row = [self rowAtPoint: [self convertPoint: [e locationInWindow] fromView: nil]];
if( row >= 0 )
if (row >= 0)
{
if (![self isRowSelected: row])
[self selectRowIndexes: [NSIndexSet indexSetWithIndex: row]