From 76d1d9d7fe2046bcf9281f95c5a7b541d49e6a0b Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Tue, 24 Apr 2012 00:05:50 +0000 Subject: - Rework edit sheet find/replace handling; instead of altering the main window's firstResponder, which only worked under certain NSTextView focus conditions, allow the field edit sheet to become the main window. This fixes issues with the Find/Replace dialog not fully working correctly in the edit sheet. --- Source/SPWindow.m | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'Source/SPWindow.m') diff --git a/Source/SPWindow.m b/Source/SPWindow.m index 9353e80d..213d7740 100644 --- a/Source/SPWindow.m +++ b/Source/SPWindow.m @@ -27,6 +27,8 @@ @implementation SPWindow +@synthesize isSheetWhichCanBecomeMain; + #pragma mark - #pragma mark Keyboard shortcut additions @@ -115,6 +117,9 @@ [super sendEvent:theEvent]; } +#pragma mark - +#pragma mark Undo manager handling + /** * If this window is controlled by an SPWindowController, and thus supports being asked * for the frontmost SPTableDocument, request the undoController for that table @@ -129,4 +134,27 @@ return [super undoManager]; } +#pragma mark - +#pragma mark Method overrides + +/** + * Allow sheets to become main if necessary, for example if they are acting as an + * editor for a window. + */ +- (BOOL)canBecomeMainWindow +{ + + // If this window is a sheet which is permitted to become main, respond appropriately + if ([self isSheet] && isSheetWhichCanBecomeMain) { + return [self isVisible]; + } + + // Otherwise, if this window has a sheet attached which can become main, return NO. + if ([[self attachedSheet] isKindOfClass:[SPWindow class]] && [(SPWindow *)[self attachedSheet] isSheetWhichCanBecomeMain]) { + return NO; + } + + return [super canBecomeMainWindow]; +} + @end -- cgit v1.2.3