-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
78 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// XTTableView.h | ||
// | ||
// | ||
// Created by finn on 2020/6/30. | ||
// Copyright © 2020 finn. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
@protocol XTMenuDelegate <NSObject> | ||
- (NSMenu*)tableView:(NSTableView*)aTableView menuForRows:(NSIndexSet*)rows; | ||
- (NSMenu*)emptySelectionTableView:(NSTableView*)aTableView; | ||
|
||
@end | ||
@interface XTTableView : NSTableView | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// XTTableView.m | ||
// | ||
// | ||
// Created by finn on 2020/6/30. | ||
// Copyright © 2020 finn. All rights reserved. | ||
// | ||
|
||
#import "XTTableView.h" | ||
|
||
@implementation XTTableView | ||
|
||
- (void)drawRect:(NSRect)dirtyRect { | ||
[super drawRect:dirtyRect]; | ||
|
||
// Drawing code here. | ||
} | ||
- (NSMenu*)menuForEvent:(NSEvent*)event | ||
{ | ||
NSPoint location = [self convertPoint:[event locationInWindow] fromView:nil]; | ||
NSInteger row = [self rowAtPoint:location]; | ||
if (!(row >= 0) || ([event type] != NSRightMouseDown)) { | ||
if ([[self delegate] respondsToSelector:@selector(emptySelectionTableView:)]) { | ||
return [(id)[self delegate] emptySelectionTableView:self]; | ||
} | ||
return [super menuForEvent:event]; | ||
} | ||
NSIndexSet *selected = [self selectedRowIndexes]; | ||
if (![selected containsIndex:row]) { | ||
selected = [NSIndexSet indexSetWithIndex:row]; | ||
[self selectRowIndexes:selected byExtendingSelection:NO]; | ||
} | ||
if ([[self delegate] respondsToSelector:@selector(tableView:menuForRows:)]) { | ||
return [(id)[self delegate] tableView:self menuForRows:selected]; | ||
} | ||
return [super menuForEvent:event]; | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters