properly enable/disable the rename confirm button

This commit is contained in:
Mitchell Livingston
2013-02-08 23:26:07 +00:00
parent b15027b8ce
commit 8d83fa4d00
2 changed files with 9 additions and 4 deletions

View File

@@ -16,6 +16,7 @@
Torrent * _torrent;
FileListNode * _node;
void (^_completionHandler)(BOOL);
NSString * _originalName;
IBOutlet NSTextField * _labelField;
IBOutlet NSTextField * _inputField;

View File

@@ -18,6 +18,8 @@ typedef void (^CompletionBlock)(BOOL);
@property (nonatomic, retain) FileListNode * node;
@property (nonatomic, copy) CompletionBlock completionHandler;
@property (nonatomic, copy) NSString * originalName;
@end
@implementation FileRenameSheetController
@@ -26,6 +28,7 @@ typedef void (^CompletionBlock)(BOOL);
@synthesize torrent = _torrent;
@synthesize node = _node;
@synthesize completionHandler = _completionHandler;
@synthesize originalName = _originalName;
@synthesize labelField = _labelField;
@synthesize inputField = _inputField;
@synthesize renameButton = _renameButton;
@@ -75,6 +78,7 @@ typedef void (^CompletionBlock)(BOOL);
[_torrent release];
[_node release];
[_completionHandler release];
[_originalName release];
[super dealloc];
}
@@ -82,11 +86,11 @@ typedef void (^CompletionBlock)(BOOL);
{
[super windowDidLoad];
NSString * name = [self.node name] ?: [self.torrent name];
NSString * label = [NSString stringWithFormat: NSLocalizedString(@"Rename the file \"%@\":", "rename sheet label"), name];
self.originalName = [self.node name] ?: [self.torrent name];
NSString * label = [NSString stringWithFormat: NSLocalizedString(@"Rename the file \"%@\":", "rename sheet label"), self.originalName];
[self.labelField setStringValue: label];
[self.inputField setStringValue: name];
[self.inputField setStringValue: self.originalName];
[self.renameButton setEnabled: NO];
#warning size these
@@ -119,7 +123,7 @@ typedef void (^CompletionBlock)(BOOL);
- (void) controlTextDidChange: (NSNotification *) notification
{
[self.renameButton setEnabled: ![[self.inputField stringValue] isEqualToString: @""] && ![[self.inputField stringValue] isEqualToString: [self.torrent name]]];
[self.renameButton setEnabled: ![[self.inputField stringValue] isEqualToString: @""] && ![[self.inputField stringValue] isEqualToString: self.originalName]];
}
@end