Implemented Edit button; it must be clicked to modify an entry.

This commit is contained in:
Chhom Seng
2014-01-01 19:10:03 -07:00
parent ce838f6b7a
commit da93396ee7
5 changed files with 84 additions and 12 deletions

View File

@@ -2,10 +2,10 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1080</int>
<string key="IBDocument.SystemVersion">13A603</string>
<string key="IBDocument.SystemVersion">13B42</string>
<string key="IBDocument.InterfaceBuilderVersion">4514</string>
<string key="IBDocument.AppKitVersion">1265</string>
<string key="IBDocument.HIToolboxVersion">695.00</string>
<string key="IBDocument.HIToolboxVersion">696.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">4514</string>
@@ -328,6 +328,14 @@
</object>
<int key="connectionID">3122</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">handleEditButtonClickEvent:</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="348505851"/>
</object>
<int key="connectionID">3125</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
@@ -988,7 +996,7 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">3123</int>
<int key="maxID">3125</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -1003,17 +1011,20 @@
<object class="IBPartialClassDescription">
<string key="className">MPInspectorViewController</string>
<string key="superclassName">MPViewController</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">showImagePopup:</string>
<string key="NS.object.0">id</string>
<dictionary class="NSMutableDictionary" key="actions">
<string key="handleEditButtonClickEvent:">id</string>
<string key="showImagePopup:">id</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="actionInfosByName">
<object class="IBActionInfo" key="handleEditButtonClickEvent:">
<string key="name">handleEditButtonClickEvent:</string>
<string key="candidateClassName">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">showImagePopup:</string>
<object class="IBActionInfo" key="NS.object.0">
<object class="IBActionInfo" key="showImagePopup:">
<string key="name">showImagePopup:</string>
<string key="candidateClassName">id</string>
</object>
</object>
</dictionary>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="bottomBar">HNHGradientView</string>
<string key="createdTextField">NSTextField</string>

View File

@@ -44,6 +44,7 @@
- (IBAction)addCustomField:(id)sender;
- (IBAction)removeCustomField:(id)sender;
- (void)beginEditing;
- (void)endEditing;
@end

View File

@@ -184,6 +184,39 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
[self.entry removeBinary:binary];
}
// CS: could there be a better way?
- (void)beginEditing
{
NSLog(@"beganEditing:");
_titleTextField.editable = YES;
_usernameTextField.editable = YES;
_URLTextField.editable = YES;
_passwordTextField.editable = YES;
_createdTextField.editable = YES;
_modifiedTextField.editable = YES;
_notesTextView.editable = YES;
}
// CS: could there be a better way?
- (void)endEditing
{
NSLog(@"endEditing");
_titleTextField.editable = NO;
_usernameTextField.editable = NO;
_URLTextField.editable = NO;
_passwordTextField.editable = NO;
_createdTextField.editable = NO;
_modifiedTextField.editable = NO;
_notesTextView.editable = NO;
}
#pragma mark -
#pragma mark Popovers

View File

@@ -22,6 +22,7 @@
@property (weak) IBOutlet NSButton *editButton;
- (IBAction)showImagePopup:(id)sender;
- (IBAction)handleEditButtonClickEvent:(id)sender;
/* Seperate call to ensure alle registered objects are in place */
- (void)setupNotifications:(NSWindowController *)windowController;

View File

@@ -156,6 +156,28 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
}
#pragma mark -
#pragma mark Click Edit Button
// button title can be used as a status indicator
- (IBAction)handleEditButtonClickEvent:(id)sender
{
NSString *buttonTitle;
buttonTitle = self.editButton.title;
if ([buttonTitle isEqualToString:@"Edit"]) {
NSLog(@"begin editing");
[_entryViewController beginEditing];
self.editButton.title = @"Done";
}
else if ([buttonTitle isEqualToString:@"Done"]) {
NSLog(@"finished editing");
[_entryViewController endEditing];
self.editButton.title = @"Edit";
}
}
#pragma mark -
#pragma mark Popup
- (IBAction)showImagePopup:(id)sender {
@@ -246,5 +268,9 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
}
}
[self _updateItemBindings:document.selectedItem];
// disable the entry text fields whenever the entry selection changes
[_entryViewController endEditing];
self.editButton.title = @"Edit";
}
@end