Added type-select for the file drawer. Hazahs are in order!
parent
7f54e2fc9e
commit
70ba5f7c30
|
@ -1,4 +1,5 @@
|
|||
#import "AppController.h"
|
||||
#import "KFTypeSelectTableView.h""
|
||||
|
||||
@implementation AppController
|
||||
|
||||
|
@ -8,6 +9,11 @@
|
|||
if (self)
|
||||
{
|
||||
[self initDefaults];
|
||||
|
||||
/* Use KFTypeSelectTableView as our NSTableView base class to allow type-select searching of all
|
||||
* table and outline views.
|
||||
*/
|
||||
[[KFTypeSelectTableView class] poseAsClass:[NSTableView class]];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
8E4E7C1B0AA1ED4500D11405 /* file_gray.png in Resources */ = {isa = PBXBuildFile; fileRef = 8E4E7C190AA1ED4500D11405 /* file_gray.png */; };
|
||||
8E53E8610A44C11B007E5BCE /* ID3Tag.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E53E8600A44C11B007E5BCE /* ID3Tag.framework */; };
|
||||
8E53E8690A44C121007E5BCE /* ID3Tag.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8E53E8600A44C11B007E5BCE /* ID3Tag.framework */; };
|
||||
8E57824B0B88B7AC00C97376 /* KFTypeSelectTableView.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8E5782490B88B7AC00C97376 /* KFTypeSelectTableView.h */; };
|
||||
8E57824C0B88B7AC00C97376 /* KFTypeSelectTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E57824A0B88B7AC00C97376 /* KFTypeSelectTableView.m */; };
|
||||
8E6889240AAA403C00AD3950 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E6889230AAA403C00AD3950 /* Carbon.framework */; };
|
||||
8E6A8E2C0A0D8A68002ABE9C /* CoreAudioFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E6A8E280A0D8A68002ABE9C /* CoreAudioFile.m */; };
|
||||
8E6A8E380A0D8AD8002ABE9C /* CoreAudioUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E6A8E360A0D8AD8002ABE9C /* CoreAudioUtils.m */; };
|
||||
|
@ -192,6 +194,7 @@
|
|||
171678BF0AC8C39E00C28CF3 /* SmartFolderNode.h in CopyFiles */,
|
||||
8E76ED760B877C0700494D51 /* AMRemovableColumnsTableView.h in CopyFiles */,
|
||||
8E76ED780B877C0700494D51 /* AMRemovableTableColumn.h in CopyFiles */,
|
||||
8E57824B0B88B7AC00C97376 /* KFTypeSelectTableView.h in CopyFiles */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -227,6 +230,8 @@
|
|||
8E4E7C180AA1ED4500D11405 /* file_blue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = file_blue.png; sourceTree = "<group>"; };
|
||||
8E4E7C190AA1ED4500D11405 /* file_gray.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = file_gray.png; sourceTree = "<group>"; };
|
||||
8E53E8600A44C11B007E5BCE /* ID3Tag.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ID3Tag.framework; path = Libraries/ID3Tag/build/Release/ID3Tag.framework; sourceTree = "<group>"; };
|
||||
8E5782490B88B7AC00C97376 /* KFTypeSelectTableView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = KFTypeSelectTableView.h; sourceTree = "<group>"; };
|
||||
8E57824A0B88B7AC00C97376 /* KFTypeSelectTableView.m */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 30; path = KFTypeSelectTableView.m; sourceTree = "<group>"; };
|
||||
8E643DF20A2B585600844A28 /* GameFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameFile.h; sourceTree = "<group>"; };
|
||||
8E643DF30A2B585600844A28 /* GameFile.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GameFile.mm; sourceTree = "<group>"; };
|
||||
8E6889230AAA403C00AD3950 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
|
||||
|
@ -532,6 +537,8 @@
|
|||
8E75751A09F31D5A0080F1EE /* Custom */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8E5782490B88B7AC00C97376 /* KFTypeSelectTableView.h */,
|
||||
8E57824A0B88B7AC00C97376 /* KFTypeSelectTableView.m */,
|
||||
8E76ED720B877C0700494D51 /* AMRemovableColumnsTableView.h */,
|
||||
8E76ED730B877C0700494D51 /* AMRemovableColumnsTableView.m */,
|
||||
8E76ED740B877C0700494D51 /* AMRemovableTableColumn.h */,
|
||||
|
@ -902,6 +909,7 @@
|
|||
171678C00AC8C39E00C28CF3 /* SmartFolderNode.m in Sources */,
|
||||
8E76ED770B877C0700494D51 /* AMRemovableColumnsTableView.m in Sources */,
|
||||
8E76ED790B877C0700494D51 /* AMRemovableTableColumn.m in Sources */,
|
||||
8E57824C0B88B7AC00C97376 /* KFTypeSelectTableView.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
//
|
||||
// KFTypeSelectTableView.h
|
||||
// KFTypeSelectTableView v1.0.4
|
||||
//
|
||||
// Keyboard navigation enabled table view. Suitable for
|
||||
// class posing as well as normal use.
|
||||
//
|
||||
// All delegate methods are optional, except you need to implement typeSelectTableView:stringValueForTableColumn:row:
|
||||
// if you're using bindings to supply the table view with data.
|
||||
//
|
||||
// ------------------------------------------------------------------------
|
||||
// Copyright (c) 2005, Ken Ferry All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// (1) Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// (2) Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// (3) Neither Ken Ferry's name nor the names of other contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||
// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ------------------------------------------------------------------------
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#pragma mark constants
|
||||
|
||||
typedef enum KFTypeSelectMatchAlgorithm {
|
||||
KFSubstringMatchAlgorithm = 0,
|
||||
KFPrefixMatchAlgorithm = 1
|
||||
} KFTypeSelectMatchAlgorithm;
|
||||
|
||||
@interface KFTypeSelectTableView : NSTableView
|
||||
|
||||
#pragma mark action methods
|
||||
|
||||
// these beep if the operation cannot be performed
|
||||
- (void)findNext:(id)sender;
|
||||
- (void)findPrevious:(id)sender;
|
||||
|
||||
#pragma mark accessors
|
||||
// KVO-compliant
|
||||
- (NSString *)pattern;
|
||||
|
||||
// a tableview with no match algorithm set uses defaultMatchAlgorithm
|
||||
// defaultMatchAlgorithm defaults to KFPrefixMatchAlgorithm
|
||||
+ (KFTypeSelectMatchAlgorithm)defaultMatchAlgorithm;
|
||||
+ (void)setDefaultMatchAlgorithm:(KFTypeSelectMatchAlgorithm)algorithm;
|
||||
|
||||
- (KFTypeSelectMatchAlgorithm)matchAlgorithm;
|
||||
- (void)setMatchAlgorithm:(KFTypeSelectMatchAlgorithm)algorithm;
|
||||
|
||||
// defaults to NO
|
||||
- (BOOL)searchWraps;
|
||||
- (void)setSearchWraps:(BOOL)flag;
|
||||
|
||||
// supply a set of identifiers to limit columns searched for match.
|
||||
// Only columns with identifiers in the provided set are searched.
|
||||
// nil identifiers means search all columns. defaults to nil.
|
||||
- (NSSet *)searchColumnIdentifiers;
|
||||
- (void)setSearchColumnIdentifiers:(NSSet *)identifiers;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSObject (KFTypeSelectTableViewDelegate)
|
||||
|
||||
#pragma mark configuration methods
|
||||
|
||||
// Implement this method if the table uses bindings for data.
|
||||
// Use something like
|
||||
// return [[[arrayController arrangedObjects] objectAtIndex:row] valueForKey:[column identifier]];
|
||||
// Could also use it to supply string representations for non-string data, or to search only part of visible text.
|
||||
- (NSString *)typeSelectTableView:(id)tableView stringValueForTableColumn:(NSTableColumn *)column row:(int)row;
|
||||
|
||||
// defaults to YES
|
||||
- (BOOL)typeSelectTableViewSearchTopToBottom:(id)tableView;
|
||||
|
||||
// defaults to first or last row, depending on direction of search
|
||||
- (int)typeSelectTableViewInitialSearchRow:(id)tableView;
|
||||
|
||||
// A hook for cases (like mail plugin) where there's no good place to configure the table.
|
||||
// Will be called before type-select is used with any particular delegate.
|
||||
- (void)configureTypeSelectTableView:(id)tableView;
|
||||
|
||||
#pragma mark reporting methods
|
||||
// pattern of @"" indicates no search, anything else means a search is in progress
|
||||
// userInfo dictionary has @"oldPattern" key
|
||||
// this notification is sent
|
||||
// when a search begins or is modified
|
||||
// when a search is cancelled
|
||||
// x seconds after a search either succeeds or fails, where x is a timeout period
|
||||
- (void)typeSelectTableViewPatternDidChange:(NSNotification *)aNotification;
|
||||
- (void)typeSelectTableView:(id)tableView didFindMatch:(NSString *)match range:(NSRange)matchedRange forPattern:(NSString *)pattern;
|
||||
- (void)typeSelectTableView:(id)tableView didFailToFindMatchForPattern:(NSString *)pattern; // fallback is a beep if delegate does not implement
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark notifications
|
||||
// delegate automatically receives this notification. See delegate method above.
|
||||
extern NSString *KFTypeSelectTableViewPattenDidChangeNotification;
|
File diff suppressed because it is too large
Load Diff
|
@ -3,13 +3,13 @@
|
|||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IBDocumentLocation</key>
|
||||
<string>66 -65 639 388 0 0 1024 746 </string>
|
||||
<string>61 -9 639 388 0 0 1024 746 </string>
|
||||
<key>IBEditorPositions</key>
|
||||
<dict>
|
||||
<key>1063</key>
|
||||
<string>0 228 136 49 0 0 1024 746 </string>
|
||||
<key>1156</key>
|
||||
<string>233 341 241 366 0 0 1024 746 </string>
|
||||
<string>391 336 241 366 0 0 1024 746 </string>
|
||||
<key>29</key>
|
||||
<string>85 683 383 44 0 0 1024 746 </string>
|
||||
<key>463</key>
|
||||
|
@ -33,9 +33,10 @@
|
|||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>513</integer>
|
||||
<integer>463</integer>
|
||||
<integer>1156</integer>
|
||||
<integer>29</integer>
|
||||
<integer>21</integer>
|
||||
<integer>463</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>8L127</string>
|
||||
|
|
Binary file not shown.
|
@ -22,5 +22,4 @@
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -9,12 +9,15 @@
|
|||
#import "FileOutlineView.h"
|
||||
#import "FileIconCell.h"
|
||||
|
||||
@interface FileOutlineView (KFTypeSelectTableViewSupport)
|
||||
- (void)findPrevious:(id)sender;
|
||||
- (void)findNext:(id)sender;
|
||||
@end
|
||||
|
||||
@implementation FileOutlineView
|
||||
|
||||
- (void) awakeFromNib
|
||||
{
|
||||
NSLog(@"FILE OUTLINE VIEW");
|
||||
|
||||
NSEnumerator *e = [[self tableColumns] objectEnumerator];
|
||||
id c;
|
||||
while ((c = [e nextObject]))
|
||||
|
@ -27,5 +30,38 @@
|
|||
[c setDataCell: dataCell];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Navigate outline view with the keyboard, send select actions to delegate
|
||||
- (void)keyDown:(NSEvent *)theEvent
|
||||
{
|
||||
if (!([theEvent modifierFlags] & NSCommandKeyMask)) {
|
||||
|
||||
NSString *charString = [theEvent charactersIgnoringModifiers];
|
||||
unichar pressedChar = 0;
|
||||
|
||||
//Get the pressed character
|
||||
if ([charString length] == 1) pressedChar = [charString characterAtIndex:0];
|
||||
|
||||
if ((pressedChar == '\031') && // backtab
|
||||
([self respondsToSelector:@selector(findPrevious:)])) {
|
||||
/* KFTypeSelectTableView supports findPrevious; backtab is added to AIOutlineView as a find previous action
|
||||
* if KFTypeSelectTableView is being used via posing */
|
||||
[self findPrevious:self];
|
||||
|
||||
} else if ((pressedChar == '\t') &&
|
||||
([self respondsToSelector:@selector(findNext:)])) {
|
||||
/* KFTypeSelectTableView supports findNext; tab is added to AIOutlineView as a find next action
|
||||
* if KFTypeSelectTableView is being used via posing */
|
||||
[self findNext:self];
|
||||
|
||||
} else {
|
||||
[super keyDown:theEvent];
|
||||
}
|
||||
} else {
|
||||
[super keyDown:theEvent];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#import "FileTreeController.h"
|
||||
#import "DirectoryNode.h"
|
||||
#import "ImageTextCell.h"
|
||||
#import "KFTypeSelectTableView.h"
|
||||
|
||||
@implementation FileTreeController
|
||||
|
||||
|
@ -116,27 +117,6 @@
|
|||
return watcher;
|
||||
}
|
||||
|
||||
// Required Protocol Bullshit (RPB)
|
||||
- (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
//End of RPB
|
||||
|
||||
- (BOOL)outlineView:(NSOutlineView *)olv writeItems:(NSArray*)items toPasteboard:(NSPasteboard*)pboard {
|
||||
//Get selected paths
|
||||
NSLog(@"Items: %@", items);
|
||||
|
@ -164,5 +144,27 @@
|
|||
return YES;
|
||||
}
|
||||
|
||||
//For type-select
|
||||
|
||||
- (void)configureTypeSelectTableView:(KFTypeSelectTableView *)tableView
|
||||
{
|
||||
[tableView setSearchWraps:YES];
|
||||
}
|
||||
|
||||
- (int)typeSelectTableViewInitialSearchRow:(id)tableView
|
||||
{
|
||||
return [tableView selectedRow];
|
||||
}
|
||||
|
||||
// Return the string value used for type selection
|
||||
- (NSString *)typeSelectTableView:(KFTypeSelectTableView *)tableView stringValueForTableColumn:(NSTableColumn *)col row:(int)row
|
||||
{
|
||||
id item = [tableView itemAtRow:row];
|
||||
|
||||
//Reaching down into NSTreeController...yikes
|
||||
return [[[item observedObject] path] lastPathComponent];
|
||||
}
|
||||
|
||||
//End type-select
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue