aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/SPEditSheetTextView.m17
-rw-r--r--Source/SPFieldEditorController.h3
-rw-r--r--Source/SPFieldEditorController.m17
-rw-r--r--Source/SPWindow.h5
-rw-r--r--Source/SPWindow.m28
5 files changed, 40 insertions, 30 deletions
diff --git a/Source/SPEditSheetTextView.m b/Source/SPEditSheetTextView.m
index b028c177..a5d110a6 100644
--- a/Source/SPEditSheetTextView.m
+++ b/Source/SPEditSheetTextView.m
@@ -343,21 +343,4 @@
[self saveChangedFontInUserDefaults];
}
-/**
- * Needed to allow Find Panel inside the textView if it runs in a sheet
- */
-- (BOOL)becomeFirstResponder
-{
- return YES;
-}
-
-/**
- * Needed to allow Find Panel inside the textView if it runs in a sheet
- */
-- (BOOL)resignFirstResponder
-{
- return YES;
-}
-
-
@end
diff --git a/Source/SPFieldEditorController.h b/Source/SPFieldEditorController.h
index 4e978646..1fc3f812 100644
--- a/Source/SPFieldEditorController.h
+++ b/Source/SPFieldEditorController.h
@@ -22,6 +22,7 @@
//
// More info at <http://code.google.com/p/sequel-pro/>
+@class SPWindow;
/**
* @class SPFieldEditorController SPFieldEditorController.h
@@ -44,7 +45,7 @@
IBOutlet id hexTextView;
IBOutlet id editTextScrollView;
IBOutlet id hexTextScrollView;
- IBOutlet id editSheet;
+ IBOutlet SPWindow *editSheet;
IBOutlet id editSheetCancelButton;
IBOutlet id editSheetIsNotEditableCancelButton;
IBOutlet id editSheetOkButton;
diff --git a/Source/SPFieldEditorController.m b/Source/SPFieldEditorController.m
index 3a4ee14c..f94af537 100644
--- a/Source/SPFieldEditorController.m
+++ b/Source/SPFieldEditorController.m
@@ -32,6 +32,7 @@
#import "SPTooltip.h"
#import "SPGeometryDataView.h"
#import "SPCopyTable.h"
+#import "SPWindow.h"
#include <objc/objc-runtime.h>
#import "SPCustomQuery.h"
#import "SPTableContent.h"
@@ -85,6 +86,10 @@
// Allow the user to enter cmd+return to close the edit sheet in addition to fn+return
[editSheetOkButton setKeyEquivalentModifierMask:NSCommandKeyMask];
+ // Permit the field edit sheet to become main if necessary; this allows fields within the sheet to
+ // support full interactivity, for example use of the NSFindPanel inside NSTextViews.
+ [editSheet setIsSheetWhichCanBecomeMain:YES];
+
allowUndo = NO;
selectionChanged = NO;
@@ -431,19 +436,7 @@
editSheetWillBeInitialized = NO;
[editSheetProgressBar stopAnimation:self];
-
- // The field editor sheet runs as sheet thus a NSTextView won't respond to the Find Panel
- // since the Find Panel validate its buttons against [[NSApp mainWindow] firstResponder] == NSTextView.
- // After ordering out this sheet SPCopyTable remains the first responder thus set it hard.
- // This only works in conjunction with [NSTextView becomeFirstResponder] and [NSTextView resignFirstResponder]
- // which has to return YES.
-#ifndef SP_REFACTOR
- if([[self window] firstResponder] == editTextView)
- [[NSApp mainWindow] makeFirstResponder:[[self window] firstResponder]];
-#endif
-
}
-
}
/**
diff --git a/Source/SPWindow.h b/Source/SPWindow.h
index 74c4f804..9809f3d3 100644
--- a/Source/SPWindow.h
+++ b/Source/SPWindow.h
@@ -25,5 +25,10 @@
#import <Cocoa/Cocoa.h>
@interface SPWindow : NSWindow
+{
+ BOOL isSheetWhichCanBecomeMain;
+}
+
+@property (assign) BOOL isSheetWhichCanBecomeMain;
@end
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