mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 20:02:27 +00:00
iconselection and date picking now get registered as user interaction
This commit is contained in:
@@ -60,7 +60,9 @@ typedef NS_ENUM(NSUInteger, MPDatePreset) {
|
|||||||
|
|
||||||
- (IBAction)useDate:(id)sender {
|
- (IBAction)useDate:(id)sender {
|
||||||
KPKTimeInfo *timeInfo = [self.representedObject timeInfo];
|
KPKTimeInfo *timeInfo = [self.representedObject timeInfo];
|
||||||
|
[self willChangeValueForRepresentedObjectKeyPath:[NSString stringWithFormat:@"%@.%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(timeInfo)), NSStringFromSelector(@selector(expirationDate))]];
|
||||||
timeInfo.expirationDate = self.datePicker.dateValue;
|
timeInfo.expirationDate = self.datePicker.dateValue;
|
||||||
|
[self didChangeValueForRepresentedObjectKeyPath:[NSString stringWithFormat:@"%@.%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(timeInfo)), NSStringFromSelector(@selector(expirationDate))]];
|
||||||
[self.view.window performClose:sender];
|
[self.view.window performClose:sender];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,9 +60,6 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
|
|||||||
|
|
||||||
@implementation MPEntryInspectorViewController
|
@implementation MPEntryInspectorViewController
|
||||||
|
|
||||||
static NSString *kMPContentBindingString2 = @"content.%@.%@";
|
|
||||||
static NSString *kMPContentBindingString3 = @"content.%@.%@.%@";
|
|
||||||
|
|
||||||
- (NSString *)nibName {
|
- (NSString *)nibName {
|
||||||
return @"EntryInspectorView";
|
return @"EntryInspectorView";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,8 +34,9 @@
|
|||||||
|
|
||||||
- (IBAction)useDefault:(id)sender {
|
- (IBAction)useDefault:(id)sender {
|
||||||
KPKNode *node = self.representedObject;
|
KPKNode *node = self.representedObject;
|
||||||
|
[self willChangeValueForRepresentedObjectKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(iconId))]];
|
||||||
node.iconId = [[node class] defaultIcon];
|
node.iconId = [[node class] defaultIcon];
|
||||||
|
[self didChangeValueForRepresentedObjectKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(iconId))]];
|
||||||
[self.view.window performClose:sender];
|
[self.view.window performClose:sender];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +50,11 @@
|
|||||||
NSUInteger buttonIndex = [self.iconCollectionView.content indexOfObject:image];
|
NSUInteger buttonIndex = [self.iconCollectionView.content indexOfObject:image];
|
||||||
NSInteger newIconId = ((NSNumber *)[MPIconHelper databaseIconTypes][buttonIndex]).integerValue;
|
NSInteger newIconId = ((NSNumber *)[MPIconHelper databaseIconTypes][buttonIndex]).integerValue;
|
||||||
KPKNode *node = self.representedObject;
|
KPKNode *node = self.representedObject;
|
||||||
|
[self willChangeValueForRepresentedObjectKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(iconId))]];
|
||||||
node.iconId = newIconId;
|
node.iconId = newIconId;
|
||||||
|
[self didChangeValueForRepresentedObjectKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(representedObject)), NSStringFromSelector(@selector(iconId))]];
|
||||||
[self.view.window performClose:sender];
|
[self.view.window performClose:sender];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -176,6 +176,10 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
|||||||
self.popover.delegate = self;
|
self.popover.delegate = self;
|
||||||
self.popover.behavior = NSPopoverBehaviorTransient;
|
self.popover.behavior = NSPopoverBehaviorTransient;
|
||||||
MPIconSelectViewController *vc = [[MPIconSelectViewController alloc] init];
|
MPIconSelectViewController *vc = [[MPIconSelectViewController alloc] init];
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
|
selector:@selector(_willChangeValueForRepresentedObjectNotification:)
|
||||||
|
name:MPViewControllerWillChangeValueForRepresentedObjectKeyPathNotification
|
||||||
|
object:vc];
|
||||||
vc.representedObject = self.representedObject;
|
vc.representedObject = self.representedObject;
|
||||||
vc.popover = self.popover;
|
vc.popover = self.popover;
|
||||||
self.popover.contentViewController = vc;
|
self.popover.contentViewController = vc;
|
||||||
@@ -191,6 +195,10 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
|||||||
self.popover.delegate = self;
|
self.popover.delegate = self;
|
||||||
self.popover.behavior = NSPopoverBehaviorTransient;
|
self.popover.behavior = NSPopoverBehaviorTransient;
|
||||||
MPDatePickingViewController *vc = [[MPDatePickingViewController alloc] init];
|
MPDatePickingViewController *vc = [[MPDatePickingViewController alloc] init];
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
|
selector:@selector(_willChangeValueForRepresentedObjectNotification:)
|
||||||
|
name:MPViewControllerWillChangeValueForRepresentedObjectKeyPathNotification
|
||||||
|
object:vc];
|
||||||
vc.representedObject = self.representedObject;
|
vc.representedObject = self.representedObject;
|
||||||
self.popover.contentViewController = vc;
|
self.popover.contentViewController = vc;
|
||||||
[self.popover showRelativeToRect:NSZeroRect ofView:sender preferredEdge:NSMinYEdge];
|
[self.popover showRelativeToRect:NSZeroRect ofView:sender preferredEdge:NSMinYEdge];
|
||||||
@@ -202,6 +210,8 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
|||||||
|
|
||||||
- (void)popoverDidClose:(NSNotification *)notification {
|
- (void)popoverDidClose:(NSNotification *)notification {
|
||||||
/* clear out the popover */
|
/* clear out the popover */
|
||||||
|
NSPopover *po = notification.object;
|
||||||
|
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPViewControllerWillChangeValueForRepresentedObjectKeyPathNotification object:po.contentViewController];
|
||||||
self.popover = nil;
|
self.popover = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,6 +219,7 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
|||||||
#pragma mark Bindings
|
#pragma mark Bindings
|
||||||
|
|
||||||
- (void)willChangeValueForRepresentedObjectKeyPath:(NSString *)keyPath {
|
- (void)willChangeValueForRepresentedObjectKeyPath:(NSString *)keyPath {
|
||||||
|
[super willChangeValueForKey:keyPath];
|
||||||
[self _recordChangesForCurrentNode];
|
[self _recordChangesForCurrentNode];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,19 +24,19 @@ APPKIT_EXTERN NSString *const MPViewControllerDidChangeValueForRepresentedObject
|
|||||||
* Override this to get notificied when setValue:forKeyPath will be called with a keypath starting with representedObject.
|
* Override this to get notificied when setValue:forKeyPath will be called with a keypath starting with representedObject.
|
||||||
* This is always called via the binding system, hence it's usefull to anticipate model changes via the ui
|
* This is always called via the binding system, hence it's usefull to anticipate model changes via the ui
|
||||||
*
|
*
|
||||||
* The default implementation calls this just befor setValue:forKeyPath:
|
* The default implementation calls this just befor setValue:forKeyPath: and posts a MPViewControllerWillChangeValueForRepresentedObjectKeyPathNotification
|
||||||
|
* If you override this, you shoudl call super to ensure well defined behaviour
|
||||||
*
|
*
|
||||||
* @param keyPath the full key path about to be affected
|
* @param keyPath the full key path about to be affected
|
||||||
*/
|
*/
|
||||||
- (void)willChangeValueForRepresentedObjectKeyPath:(NSString *)keyPath;
|
- (void)willChangeValueForRepresentedObjectKeyPath:(NSString *)keyPath;
|
||||||
/**
|
/**
|
||||||
* Override this to get notified when setValue:forKeyPath was called with a keypath starting with representedObject.
|
* Override this to get notified when setValue:forKeyPath was called with a keypath starting with representedObject.
|
||||||
* The default implementation calls this right after setValue:forKeyPath:
|
* The default implementation calls this right after setValue:forKeyPath: and will post a MPViewControllerDidChangeValueForRepresentedObjectKeyPathNotification.
|
||||||
|
* If you override this, you should call super to ensure well defined behavoir
|
||||||
*
|
*
|
||||||
* @param keyPath the full key path affected
|
* @param keyPath the full key path affected
|
||||||
*/
|
*/
|
||||||
- (void)didChangeValueForRepresentedObjectKeyPath:(NSString *)keyPath;
|
- (void)didChangeValueForRepresentedObjectKeyPath:(NSString *)keyPath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -43,10 +43,8 @@ NSString *const MPViewControllerDidChangeValueForRepresentedObjectKeyPathNotific
|
|||||||
#pragma mark Binding observation
|
#pragma mark Binding observation
|
||||||
- (void)setValue:(id)value forKeyPath:(NSString *)keyPath {
|
- (void)setValue:(id)value forKeyPath:(NSString *)keyPath {
|
||||||
if([keyPath hasPrefix:@"representedObject."]) {
|
if([keyPath hasPrefix:@"representedObject."]) {
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPViewControllerWillChangeValueForRepresentedObjectKeyPathNotification object:self];
|
|
||||||
[self willChangeValueForRepresentedObjectKeyPath:keyPath];
|
[self willChangeValueForRepresentedObjectKeyPath:keyPath];
|
||||||
[super setValue:value forKeyPath:keyPath];
|
[super setValue:value forKeyPath:keyPath];
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPViewControllerDidChangeValueForRepresentedObjectKeyPathNotification object:self];
|
|
||||||
[self didChangeValueForRepresentedObjectKeyPath:keyPath];
|
[self didChangeValueForRepresentedObjectKeyPath:keyPath];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -55,11 +53,11 @@ NSString *const MPViewControllerDidChangeValueForRepresentedObjectKeyPathNotific
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)willChangeValueForRepresentedObjectKeyPath:(NSString *)keyPath {
|
- (void)willChangeValueForRepresentedObjectKeyPath:(NSString *)keyPath {
|
||||||
NSLog(@"[%@ willChangeValueForRepresentedObjectKeyPath:%@]", NSStringFromClass([self class]), keyPath);
|
[[NSNotificationCenter defaultCenter] postNotificationName:MPViewControllerWillChangeValueForRepresentedObjectKeyPathNotification object:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)didChangeValueForRepresentedObjectKeyPath:(NSString *)keyPath {
|
- (void)didChangeValueForRepresentedObjectKeyPath:(NSString *)keyPath {
|
||||||
NSLog(@"[%@ didChangeValueForRepresentedObjectKeyPath:%@]", NSStringFromClass([self class]), keyPath);
|
[[NSNotificationCenter defaultCenter] postNotificationName:MPViewControllerDidChangeValueForRepresentedObjectKeyPathNotification object:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
Reference in New Issue
Block a user