Bugfix: Mouse click on 'Done' will process URL
This commit is contained in:
@@ -33,7 +33,7 @@
|
|||||||
#pragma mark - ModalEditDialog -
|
#pragma mark - ModalEditDialog -
|
||||||
|
|
||||||
|
|
||||||
@interface ModalEditDialog()
|
@interface ModalEditDialog() <NSWindowDelegate>
|
||||||
@property (strong) FeedGroup *feedGroup;
|
@property (strong) FeedGroup *feedGroup;
|
||||||
@property (strong) ModalSheet *modalSheet;
|
@property (strong) ModalSheet *modalSheet;
|
||||||
@end
|
@end
|
||||||
@@ -47,8 +47,10 @@
|
|||||||
}
|
}
|
||||||
/// @return New @c ModalSheet with its subclass @c .view property as dialog content.
|
/// @return New @c ModalSheet with its subclass @c .view property as dialog content.
|
||||||
- (ModalSheet *)getModalSheet {
|
- (ModalSheet *)getModalSheet {
|
||||||
if (!self.modalSheet)
|
if (!self.modalSheet) {
|
||||||
self.modalSheet = [[ModalSheet alloc] initWithView:self.view];
|
self.modalSheet = [[ModalSheet alloc] initWithView:self.view];
|
||||||
|
self.modalSheet.delegate = self;
|
||||||
|
}
|
||||||
return self.modalSheet;
|
return self.modalSheet;
|
||||||
}
|
}
|
||||||
/// This method should be overridden by subclasses. Used to save changes to persistent store.
|
/// This method should be overridden by subclasses. Used to save changes to persistent store.
|
||||||
@@ -297,6 +299,15 @@
|
|||||||
#pragma mark - NSTextField Delegate
|
#pragma mark - NSTextField Delegate
|
||||||
|
|
||||||
|
|
||||||
|
/// Window delegate will be only called on button 'Done'.
|
||||||
|
- (BOOL)windowShouldClose:(NSWindow *)sender {
|
||||||
|
if (![self.previousURL isEqualToString:self.url.stringValue]) {
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationName:NSControlTextDidEndEditingNotification object:self.url];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
/// Whenever the user finished entering the url (return key or focus change) perform a download request.
|
/// Whenever the user finished entering the url (return key or focus change) perform a download request.
|
||||||
- (void)controlTextDidEndEditing:(NSNotification *)obj {
|
- (void)controlTextDidEndEditing:(NSNotification *)obj {
|
||||||
if (obj.object == self.url) {
|
if (obj.object == self.url) {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
@interface ModalSheet()
|
@interface ModalSheet()
|
||||||
@property (weak) NSButton *btnDone;
|
@property (weak) NSButton *btnDone;
|
||||||
|
@property (assign) BOOL respondToShouldClose;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation ModalSheet
|
@implementation ModalSheet
|
||||||
@@ -36,12 +37,20 @@
|
|||||||
/// Manually disable 'Done' button if a task is still running.
|
/// Manually disable 'Done' button if a task is still running.
|
||||||
- (void)setDoneEnabled:(BOOL)accept { self.btnDone.enabled = accept; }
|
- (void)setDoneEnabled:(BOOL)accept { self.btnDone.enabled = accept; }
|
||||||
|
|
||||||
|
- (void)setDelegate:(id<NSWindowDelegate>)delegate {
|
||||||
|
[super setDelegate:delegate];
|
||||||
|
self.respondToShouldClose = [delegate respondsToSelector:@selector(windowShouldClose:)];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Called after user has clicked the 'Done' (Return) or 'Cancel' (Esc) button.
|
Called after user has clicked the 'Done' (Return) or 'Cancel' (Esc) button.
|
||||||
Flags controller as being closed @c .closeInitiated @c = @c YES.
|
Flags controller as being closed @c .closeInitiated @c = @c YES.
|
||||||
And removes all subviews (clean up).
|
And removes all subviews (clean up).
|
||||||
*/
|
*/
|
||||||
- (void)closeWithResponse:(NSModalResponse)response {
|
- (void)closeWithResponse:(NSModalResponse)response {
|
||||||
|
if (response == NSModalResponseOK && self.respondToShouldClose && ![self.delegate windowShouldClose:self]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
_didCloseAndSave = (response == NSModalResponseOK);
|
_didCloseAndSave = (response == NSModalResponseOK);
|
||||||
_didCloseAndCancel = (response != NSModalResponseOK);
|
_didCloseAndCancel = (response != NSModalResponseOK);
|
||||||
// store modal view width and remove subviews to avoid _NSKeyboardFocusClipView issues
|
// store modal view width and remove subviews to avoid _NSKeyboardFocusClipView issues
|
||||||
|
|||||||
Reference in New Issue
Block a user