mirror of
https://github.com/arsenetar/dupeguru-cocoa.git
synced 2026-01-22 14:41:40 +00:00
Convert cocoalib submodule to be in place.
This commit is contained in:
41
cocoalib/views/HSOutlineView.h
Normal file
41
cocoalib/views/HSOutlineView.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "NSTableViewAdditions.h"
|
||||
#import "NSIndexPathAdditions.h"
|
||||
|
||||
@class HSOutlineView;
|
||||
|
||||
@protocol HSOutlineViewDelegate <NSOutlineViewDelegate>
|
||||
- (NSArray *)selectedIndexPaths; /* array of NSIndexPath* */
|
||||
- (NSString *)dataForCopyToPasteboard;
|
||||
- (NSIndexPath *)internalizedPath:(NSIndexPath *)path;
|
||||
- (void)outlineViewDidEndEditing:(HSOutlineView *)outlineView;
|
||||
- (void)outlineViewCancelsEdition:(HSOutlineView *)outlineView;
|
||||
- (void)outlineViewWasDoubleClicked:(HSOutlineView *)outlineView;
|
||||
@end
|
||||
|
||||
@interface HSOutlineView : NSOutlineView
|
||||
{
|
||||
BOOL manualEditionStop;
|
||||
NSEvent *eventToIgnore;
|
||||
}
|
||||
- (id <HSOutlineViewDelegate>)delegate;
|
||||
- (void)setDelegate:(id <HSOutlineViewDelegate>)aDelegate;
|
||||
- (NSIndexPath *)selectedPath;
|
||||
- (void)selectPath:(NSIndexPath *)aPath;
|
||||
- (NSArray *)selectedNodePaths;
|
||||
- (void)selectNodePaths:(NSArray *)nodePaths;
|
||||
- (void)stopEditing;
|
||||
- (void)updateSelection;
|
||||
- (void)ignoreEventForEdition:(NSEvent *)aEvent;
|
||||
- (void)ensureExpanded:(NSIndexPath *)aPath;
|
||||
|
||||
- (IBAction)copy:(id)sender;
|
||||
@end
|
||||
190
cocoalib/views/HSOutlineView.m
Normal file
190
cocoalib/views/HSOutlineView.m
Normal file
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import "HSOutlineView.h"
|
||||
|
||||
@implementation HSOutlineView
|
||||
- (id <HSOutlineViewDelegate>)delegate
|
||||
{
|
||||
return (id <HSOutlineViewDelegate>)[super delegate];
|
||||
}
|
||||
|
||||
- (void)setDelegate:(id <HSOutlineViewDelegate>)aDelegate
|
||||
{
|
||||
[super setDelegate:aDelegate];
|
||||
id delegate = [self delegate];
|
||||
if ([delegate respondsToSelector:@selector(outlineViewWasDoubleClicked:)]) {
|
||||
[self setTarget:[self delegate]];
|
||||
[self setDoubleAction:@selector(outlineViewWasDoubleClicked:)];
|
||||
}
|
||||
}
|
||||
/* NSOutlineView overrides */
|
||||
- (void)keyDown:(NSEvent *)event
|
||||
{
|
||||
if (![self dispatchSpecialKeys:event])
|
||||
{
|
||||
[super keyDown:event];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)shouldEditTableColumn:(NSTableColumn *)column row:(NSInteger)row
|
||||
{
|
||||
BOOL result = [super shouldEditTableColumn:column row:row];
|
||||
if (!result)
|
||||
return result;
|
||||
id delegate = [self delegate];
|
||||
if ([delegate respondsToSelector:@selector(outlineView:shouldEditTableColumn:item:)])
|
||||
return [delegate outlineView:self shouldEditTableColumn:column item:[self itemAtRow:row]];
|
||||
return YES;
|
||||
}
|
||||
|
||||
/* Notifications & Delegate */
|
||||
- (void)textDidEndEditing:(NSNotification *)notification
|
||||
{
|
||||
notification = [self processTextDidEndEditing:notification];
|
||||
NSView *nextKeyView = [self nextKeyView];
|
||||
[self setNextKeyView:nil];
|
||||
[super textDidEndEditing:notification];
|
||||
[self setNextKeyView:nextKeyView];
|
||||
|
||||
if ([self editedColumn] == -1)
|
||||
{
|
||||
if (!manualEditionStop)
|
||||
{
|
||||
id delegate = [self delegate];
|
||||
if ([delegate respondsToSelector:@selector(outlineViewDidEndEditing:)])
|
||||
{
|
||||
[delegate outlineViewDidEndEditing:self];
|
||||
}
|
||||
}
|
||||
// We may have lost the focus
|
||||
[[self window] makeFirstResponder:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)textView:(NSTextView *)textView doCommandBySelector:(SEL)command
|
||||
{
|
||||
if (command == @selector(cancelOperation:))
|
||||
{
|
||||
[self stopEditing]; // The stop editing has to happen before the cancelEdits
|
||||
id delegate = [self delegate];
|
||||
if ([delegate respondsToSelector:@selector(outlineViewCancelsEdition:)])
|
||||
{
|
||||
[delegate outlineViewCancelsEdition:self];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
/* Public */
|
||||
- (NSIndexPath *)selectedPath
|
||||
{
|
||||
NSInteger row = [self selectedRow];
|
||||
return [self itemAtRow:row];
|
||||
}
|
||||
|
||||
- (void)selectPath:(NSIndexPath *)aPath
|
||||
{
|
||||
[self selectNodePaths:[NSArray arrayWithObject:aPath]];
|
||||
}
|
||||
|
||||
- (NSArray *)selectedNodePaths
|
||||
{
|
||||
NSMutableArray *r = [NSMutableArray array];
|
||||
NSIndexSet *indexes = [self selectedRowIndexes];
|
||||
NSInteger i = [indexes firstIndex];
|
||||
while (i != NSNotFound) {
|
||||
NSIndexPath *path = [self itemAtRow:i];
|
||||
[r addObject:path];
|
||||
i = [indexes indexGreaterThanIndex:i];
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
- (void)selectNodePaths:(NSArray *)aPaths
|
||||
{
|
||||
NSMutableIndexSet *toSelect = [NSMutableIndexSet indexSet];
|
||||
/* To ensure that we have correct row indexes, we must first expand all paths, and *then* select
|
||||
* row indexes.
|
||||
**/
|
||||
for (NSIndexPath *path in aPaths) {
|
||||
[self ensureExpanded:path];
|
||||
}
|
||||
for (NSIndexPath *path in aPaths) {
|
||||
[toSelect addIndex:[self rowForItem:path]];
|
||||
}
|
||||
[self selectRowIndexes:toSelect byExtendingSelection:NO];
|
||||
if ([toSelect count] > 0) {
|
||||
[self scrollRowToVisible:[toSelect firstIndex]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)ensureExpanded:(NSIndexPath *)aPath
|
||||
{
|
||||
/* Expands aPath and make sure that its parent items are expanded as well.
|
||||
*/
|
||||
id <HSOutlineViewDelegate> delegate = [self delegate];
|
||||
NSIndexPath *tmppath = [NSIndexPath indexPathWithIndex:[aPath indexAtPosition:0]];
|
||||
[self expandItem:[delegate internalizedPath:tmppath]];
|
||||
for (NSInteger i=1; i<[aPath length]; i++) {
|
||||
tmppath = [tmppath indexPathByAddingIndex:[aPath indexAtPosition:i]];
|
||||
[self expandItem:[delegate internalizedPath:tmppath]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)stopEditing
|
||||
{
|
||||
// If we're not editing, don't do anything because we don't want to steal focus from another view
|
||||
if ([self editedColumn] >= 0)
|
||||
{
|
||||
manualEditionStop = YES;
|
||||
[[self window] makeFirstResponder:self]; // This will abort edition
|
||||
manualEditionStop = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateSelection
|
||||
{
|
||||
id delegate = [self delegate];
|
||||
if ([delegate respondsToSelector:@selector(selectedIndexPaths)]) {
|
||||
[self selectNodePaths:[delegate selectedIndexPaths]];
|
||||
}
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
|
||||
- (IBAction)copy:(id)sender
|
||||
{
|
||||
NSString *data = [[self delegate] dataForCopyToPasteboard];
|
||||
if (data != nil) {
|
||||
NSPasteboard *p = [NSPasteboard generalPasteboard];
|
||||
[p declareTypes:[NSArray arrayWithObjects:NSStringPboardType, nil] owner:nil];
|
||||
[p setString:data forType:NSStringPboardType];
|
||||
}
|
||||
}
|
||||
|
||||
/* BIG HACK ZONE
|
||||
When tracking clicks in the NSTextField, the NSTableView goes in edition mode even if we click on the
|
||||
arrow or the button. The only way I found to avoid this is this scheme: let the HSOutlineView know
|
||||
of the event that caused the click, and don't go in edit mode if it happens.
|
||||
*/
|
||||
|
||||
- (void)ignoreEventForEdition:(NSEvent *)aEvent
|
||||
{
|
||||
eventToIgnore = aEvent;
|
||||
}
|
||||
|
||||
- (void)editColumn:(NSInteger)columnIndex row:(NSInteger)rowIndex withEvent:(NSEvent *)theEvent select:(BOOL)flag
|
||||
{
|
||||
if ((theEvent != nil) && (theEvent == eventToIgnore))
|
||||
return;
|
||||
[super editColumn:columnIndex row:rowIndex withEvent:theEvent select:flag];
|
||||
}
|
||||
|
||||
@end
|
||||
31
cocoalib/views/HSTableView.h
Normal file
31
cocoalib/views/HSTableView.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "NSTableViewAdditions.h"
|
||||
|
||||
@class HSTableView;
|
||||
|
||||
@protocol HSTableViewDelegate <NSTableViewDelegate>
|
||||
- (NSIndexSet *)selectedIndexes;
|
||||
- (void)tableViewDidEndEditing:(HSTableView *)tableView;
|
||||
- (void)tableViewCancelsEdition:(HSTableView *)tableView;
|
||||
- (void)tableViewWasDoubleClicked:(HSTableView *)tableView;
|
||||
@end
|
||||
|
||||
@interface HSTableView : NSTableView
|
||||
{
|
||||
BOOL manualEditionStop;
|
||||
}
|
||||
- (void)updateSelection;
|
||||
- (void)stopEditing;
|
||||
- (id <HSTableViewDelegate>)delegate;
|
||||
- (void)setDelegate:(id <HSTableViewDelegate>)aDelegate;
|
||||
- (NSScrollView *)wrapInScrollView;
|
||||
@end
|
||||
|
||||
102
cocoalib/views/HSTableView.m
Normal file
102
cocoalib/views/HSTableView.m
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import "HSTableView.h"
|
||||
#import "NSEventAdditions.h"
|
||||
|
||||
@implementation HSTableView
|
||||
/* NSTableView */
|
||||
- (void)keyDown:(NSEvent *)event
|
||||
{
|
||||
if (![self dispatchSpecialKeys:event]) {
|
||||
[super keyDown:event];
|
||||
}
|
||||
}
|
||||
|
||||
- (id <HSTableViewDelegate>)delegate
|
||||
{
|
||||
return (id <HSTableViewDelegate>)[super delegate];
|
||||
}
|
||||
|
||||
- (void)setDelegate:(id <HSTableViewDelegate>)aDelegate
|
||||
{
|
||||
[super setDelegate:aDelegate];
|
||||
id delegate = [self delegate];
|
||||
if ([delegate respondsToSelector:@selector(tableViewWasDoubleClicked:)]) {
|
||||
[self setTarget:[self delegate]];
|
||||
[self setDoubleAction:@selector(tableViewWasDoubleClicked:)];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)textDidEndEditing:(NSNotification *)notification
|
||||
{
|
||||
notification = [self processTextDidEndEditing:notification];
|
||||
NSView *nextKeyView = [self nextKeyView];
|
||||
[self setNextKeyView:nil];
|
||||
[super textDidEndEditing:notification];
|
||||
[self setNextKeyView:nextKeyView];
|
||||
|
||||
if ([self editedColumn] == -1) {
|
||||
if (!manualEditionStop) {
|
||||
id delegate = [self delegate];
|
||||
if ([delegate respondsToSelector:@selector(tableViewDidEndEditing:)]) {
|
||||
[delegate tableViewDidEndEditing:self];
|
||||
}
|
||||
}
|
||||
// We may have lost the focus
|
||||
[[self window] makeFirstResponder:self];
|
||||
}
|
||||
}
|
||||
|
||||
/* NSTextView delegate */
|
||||
- (BOOL)textView:(NSTextView *)textView doCommandBySelector:(SEL)command
|
||||
{
|
||||
if (command == @selector(cancelOperation:)) {
|
||||
[self stopEditing]; // The stop editing has to happen before the cancelEdits
|
||||
id delegate = [self delegate];
|
||||
if ([delegate respondsToSelector:@selector(tableViewCancelsEdition:)]) {
|
||||
[delegate tableViewCancelsEdition:self];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
/* Public methods */
|
||||
|
||||
- (void)updateSelection
|
||||
{
|
||||
NSIndexSet *selection = [[self delegate] selectedIndexes];
|
||||
[self selectRowIndexes:selection byExtendingSelection:NO];
|
||||
}
|
||||
|
||||
// Calling this does not result in a tableViewDidEndEditing: call
|
||||
- (void)stopEditing
|
||||
{
|
||||
// If we're not editing, don't do anything because we don't want to steal focus from another view
|
||||
if ([self editedColumn] >= 0) {
|
||||
manualEditionStop = YES;
|
||||
[[self window] makeFirstResponder:self]; // This will abort edition
|
||||
manualEditionStop = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSScrollView *)wrapInScrollView;
|
||||
{
|
||||
/* When programmatically creating an NSTableView, we have to wrap it in a scroll view for it to
|
||||
behave properly.
|
||||
*/
|
||||
NSScrollView *container = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)];
|
||||
[container setDocumentView:self];
|
||||
[container setHasVerticalScroller:YES];
|
||||
[container setHasHorizontalScroller:YES];
|
||||
[container setAutohidesScrollers:YES];
|
||||
return [container autorelease];
|
||||
}
|
||||
|
||||
@end
|
||||
20
cocoalib/views/NSIndexPathAdditions.h
Normal file
20
cocoalib/views/NSIndexPathAdditions.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
/* This is a hack to easily get around a cocoa limitation
|
||||
|
||||
In some weird circumstances, NSOutlineView calls [item indexPath] to the item instances given to
|
||||
it. I guess is expects eveyone to give it NSTreeNode instances. Anyway, because in MG, simple
|
||||
NSIndexPath are used, it causes problems. Not anymore.
|
||||
*/
|
||||
|
||||
@interface NSIndexPath(NSIndexPathAdditions)
|
||||
- (NSIndexPath *)indexPath;
|
||||
@end
|
||||
16
cocoalib/views/NSIndexPathAdditions.m
Normal file
16
cocoalib/views/NSIndexPathAdditions.m
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import "NSIndexPathAdditions.h"
|
||||
|
||||
@implementation NSIndexPath(NSIndexPathAdditions)
|
||||
- (NSIndexPath *)indexPath
|
||||
{
|
||||
return self;
|
||||
}
|
||||
@end
|
||||
24
cocoalib/views/NSTableViewAdditions.h
Normal file
24
cocoalib/views/NSTableViewAdditions.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
|
||||
@interface NSTableView(NSTableViewAdditions)
|
||||
- (BOOL)dispatchSpecialKeys:(NSEvent *)event;
|
||||
- (NSNotification *)processTextDidEndEditing:(NSNotification *)notification;
|
||||
- (void)startEditing;
|
||||
@end
|
||||
|
||||
@interface NSObject(NSTableViewAdditionsDelegate)
|
||||
- (BOOL)tableViewHadDeletePressed:(NSTableView *)tableView;
|
||||
- (BOOL)tableViewHadReturnPressed:(NSTableView *)tableView;
|
||||
- (BOOL)tableViewHadSpacePressed:(NSTableView *)tableView;
|
||||
- (BOOL)tableView:(NSTableView *)tableView receivedKeyEvent:(NSEvent *)aEvent;
|
||||
- (BOOL)shouldEditTableColumn:(NSTableColumn *)column row:(NSInteger)row;
|
||||
@end
|
||||
118
cocoalib/views/NSTableViewAdditions.m
Normal file
118
cocoalib/views/NSTableViewAdditions.m
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
Copyright 2015 Hardcoded Software (http://www.hardcoded.net)
|
||||
|
||||
This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
|
||||
which should be included with this package. The terms are also available at
|
||||
http://www.gnu.org/licenses/gpl-3.0.html
|
||||
*/
|
||||
|
||||
#import "NSTableViewAdditions.h"
|
||||
#import "NSEventAdditions.h"
|
||||
#import "Utils.h"
|
||||
|
||||
@implementation NSTableView(NSTableViewAdditions)
|
||||
|
||||
/* Private methods */
|
||||
|
||||
// Alright, this is a hack. It has been added to put in common some table and outline code, but the
|
||||
// thing is an outline view delegate doesn't use tableView:shouldEditTableColumn:row:. Anyway, for
|
||||
// the outline, just using [column isEditable] works in moneyGuru for now, so we can keep it that way.
|
||||
- (BOOL)shouldEditTableColumn:(NSTableColumn *)column row:(NSInteger)row
|
||||
{
|
||||
if (![column isEditable])
|
||||
return NO;
|
||||
id delegate = [self delegate];
|
||||
if ([delegate respondsToSelector:@selector(tableView:shouldEditTableColumn:row:)])
|
||||
{
|
||||
return [delegate tableView:self shouldEditTableColumn:column row:row];
|
||||
}
|
||||
else
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
/* Public Methods */
|
||||
|
||||
// Returns whether the responder chain should be stopeed or not
|
||||
- (BOOL)dispatchSpecialKeys:(NSEvent *)event
|
||||
{
|
||||
id delegate = [self delegate];
|
||||
if ([delegate respondsToSelector:@selector(tableView:receivedKeyEvent:)]) {
|
||||
if ([delegate tableView:self receivedKeyEvent:event]) {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
BOOL stopChain = NO;
|
||||
if ([event isDeleteOrBackspace] && [delegate respondsToSelector:@selector(tableViewHadDeletePressed:)])
|
||||
{
|
||||
stopChain = [delegate tableViewHadDeletePressed:self];
|
||||
}
|
||||
if ([event isReturnOrEnter] && [delegate respondsToSelector:@selector(tableViewHadReturnPressed:)])
|
||||
{
|
||||
stopChain = [delegate tableViewHadReturnPressed:self];
|
||||
}
|
||||
if ([event isSpace] && [delegate respondsToSelector:@selector(tableViewHadSpacePressed:)])
|
||||
{
|
||||
stopChain = [delegate tableViewHadSpacePressed:self];
|
||||
}
|
||||
if ([event isTab])
|
||||
{
|
||||
stopChain = YES;
|
||||
[[self window] makeFirstResponder:[self nextValidKeyView]];
|
||||
}
|
||||
if ([event isBackTab])
|
||||
{
|
||||
stopChain = YES;
|
||||
// Ok, this is a big hack. the normal handling of NSTableView must handle this, but we must skip over
|
||||
// a NSClipView and a NSScrollView before getting to the actual previousValidKeyView.
|
||||
// However, when we are not in Full Keyboard Access mode, there's no problem. Thus, we assume that
|
||||
// when previousValidKeyView's class is a NSClipView, it means we must perform the hack
|
||||
NSView *previous = [self previousValidKeyView];
|
||||
if ([[previous className] isEqualTo:@"NSClipView"]) // Can't use isKindOfClass, we don't want to test for a subclass
|
||||
previous = [[previous previousValidKeyView] previousValidKeyView];
|
||||
[[self window] makeFirstResponder:previous];
|
||||
}
|
||||
return stopChain;
|
||||
}
|
||||
|
||||
- (NSNotification *)processTextDidEndEditing:(NSNotification *)notification;
|
||||
{
|
||||
NSDictionary *userInfo = [notification userInfo];
|
||||
int textMovement = [[userInfo valueForKey:@"NSTextMovement"] intValue];
|
||||
if (textMovement == NSReturnTextMovement)
|
||||
{
|
||||
// Stop editing
|
||||
NSMutableDictionary *newInfo;
|
||||
newInfo = [NSMutableDictionary dictionaryWithDictionary:userInfo];
|
||||
[newInfo setObject:[NSNumber numberWithInt:NSIllegalTextMovement] forKey:@"NSTextMovement"];
|
||||
notification = [NSNotification notificationWithName:[notification name] object:[notification object] userInfo:newInfo];
|
||||
}
|
||||
return notification;
|
||||
}
|
||||
|
||||
- (void)startEditing
|
||||
{
|
||||
// Make sure one row is selected
|
||||
if ([self selectedRow] == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// We only want to edit columns that are editable. If there aren't any, don't edit.
|
||||
for (NSInteger i=0;i<[[self tableColumns] count];i++) {
|
||||
NSTableColumn *col = [[self tableColumns] objectAtIndex:i];
|
||||
if ([col isHidden]) {
|
||||
continue;
|
||||
}
|
||||
if (![self shouldEditTableColumn:col row:[self selectedRow]]) {
|
||||
continue;
|
||||
}
|
||||
// We only want one row to be selected.
|
||||
NSIndexSet *selection = [NSIndexSet indexSetWithIndex:[self selectedRow]];
|
||||
[self selectRowIndexes:selection byExtendingSelection:NO];
|
||||
[self editColumn:i row:[self selectedRow] withEvent:nil select:YES];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@end
|
||||
Reference in New Issue
Block a user