diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-10-29 12:50:12 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-10-29 12:50:12 +0000 |
commit | 497a0c7c9d30fe60763f54982b96b2cec8fa649a (patch) | |
tree | d09af2bee7cd5d39b42d3046c63a47b79027a8b4 /Source | |
parent | fb4d3131a958dabef17c3c58418e2601868e6f67 (diff) | |
download | sequelpro-497a0c7c9d30fe60763f54982b96b2cec8fa649a.tar.gz sequelpro-497a0c7c9d30fe60763f54982b96b2cec8fa649a.tar.bz2 sequelpro-497a0c7c9d30fe60763f54982b96b2cec8fa649a.zip |
• Field Editor sheet
- fixed some inconsistencies regarding window
- first humble trials to get rid of the Find Panel inside the editTextView
-- it seems that the problem is that NSTextFinder internally validates all buttons against [[NSApp mainWindow] firstResponder] == NSTextView ; in our case the [[NSApp mainWindow] firstResponder] is the calling SPCopyTable object
-- set a possible visible Find Panel to [textFinderPanel setWorksWhenModal:YES] inside the modal session ; by doing so the controls are available via keyboard and mouse but NOT the buttons
-- work on it will be continued
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPFieldEditorController.h | 2 | ||||
-rw-r--r-- | Source/SPFieldEditorController.m | 48 |
2 files changed, 37 insertions, 13 deletions
diff --git a/Source/SPFieldEditorController.h b/Source/SPFieldEditorController.h index 12342fea..af914f82 100644 --- a/Source/SPFieldEditorController.h +++ b/Source/SPFieldEditorController.h @@ -130,6 +130,8 @@ IBOutlet NSTextField *bitSheetBitLabel48; IBOutlet NSTextField *bitSheetBitLabel56; + id usedSheet; + id sheetEditData; BOOL editSheetWillBeInitialized; BOOL _isBlob; diff --git a/Source/SPFieldEditorController.m b/Source/SPFieldEditorController.m index 16823fed..56f2407d 100644 --- a/Source/SPFieldEditorController.m +++ b/Source/SPFieldEditorController.m @@ -29,6 +29,7 @@ #import "SPDataCellFormatter.h" #import "SPTooltip.h" #import "SPGeometryDataView.h" +#include <objc/objc-runtime.h> @implementation SPFieldEditorController @@ -196,7 +197,7 @@ isObjectBlob:(BOOL)isFieldBlob isEditable:(BOOL)isEditable withWindow:(NSWindow *)theWindow { - id usedSheet; + usedSheet = nil; _isEditable = isEditable; @@ -304,11 +305,11 @@ // Set window's min size since no segment and quicklook buttons are hidden if (_isBlob || _isBINARY) { - [editSheet setFrameAutosaveName:@"SPFieldEditorBlobSheet"]; - [editSheet setMinSize:NSMakeSize(560, 200)]; + [usedSheet setFrameAutosaveName:@"SPFieldEditorBlobSheet"]; + [usedSheet setMinSize:NSMakeSize(560, 200)]; } else { - [editSheet setFrameAutosaveName:@"SPFieldEditorTextSheet"]; - [editSheet setMinSize:NSMakeSize(340, 150)]; + [usedSheet setFrameAutosaveName:@"SPFieldEditorTextSheet"]; + [usedSheet setMinSize:NSMakeSize(340, 150)]; } [editTextView setEditable:_isEditable]; @@ -398,9 +399,9 @@ // Set focus if(image == nil || _isGeometry) - [editSheet makeFirstResponder:editTextView]; + [usedSheet makeFirstResponder:editTextView]; else - [editSheet makeFirstResponder:editImage]; + [usedSheet makeFirstResponder:editImage]; [stringValue release], stringValue = nil; } @@ -415,8 +416,14 @@ NSModalSession session = [NSApp beginModalSessionForWindow:usedSheet]; NSInteger cycleCounter = 0; BOOL doGroupDueToChars = NO; + BOOL findPanelIsOpen = NO; + + id textFinder = [objc_getClass("NSTextFinder") sharedTextFinder]; + id textFinderPanel = nil; + for (;;) { + // Break the run loop if editSheet was closed if ([NSApp runModalSession:session] != NSRunContinuesResponse || ![usedSheet isVisible]) @@ -426,6 +433,16 @@ [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; + + if([[textFinder findPanel:NO] isVisible]) { + textFinderPanel = [textFinder findPanel:NO]; + [textFinderPanel setWorksWhenModal:YES]; + // [textFinderPanel setLevel:NSDockWindowLevel]; + findPanelIsOpen = YES; + } else { + findPanelIsOpen = NO; + } + // Allow undo grouping if user typed a ' ' (for word level undo) // or a RETURN but not for each char due to writing speed if([[NSApp currentEvent] type] == NSKeyDown @@ -466,6 +483,11 @@ // Remember spell cheecker status [prefs setBool:[editTextView isContinuousSpellCheckingEnabled] forKey:SPBlobTextEditorSpellCheckingEnabled]; + // Close findPanel for convenience + if(findPanelIsOpen && textFinderPanel) { + [textFinderPanel close]; + } + return ( editSheetReturnCode && _isEditable ) ? (_isGeometry) ? [editTextView string] : sheetEditData : nil; } @@ -535,7 +557,7 @@ { [[NSOpenPanel openPanel] beginSheetForDirectory:nil file:@"" - modalForWindow:[self window] + modalForWindow:usedSheet modalDelegate:self didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:) contextInfo:NULL]; } @@ -552,7 +574,7 @@ [editImage setHidden:YES]; [hexTextView setHidden:YES]; [hexTextScrollView setHidden:YES]; - [[self window] makeFirstResponder:editTextView]; + [usedSheet makeFirstResponder:editTextView]; break; case 1: // image [editTextView setHidden:YES]; @@ -560,10 +582,10 @@ [editImage setHidden:NO]; [hexTextView setHidden:YES]; [hexTextScrollView setHidden:YES]; - [[self window] makeFirstResponder:editImage]; + [usedSheet makeFirstResponder:editImage]; break; case 2: // hex - load on demand - [[self window] makeFirstResponder:hexTextView]; + [usedSheet makeFirstResponder:hexTextView]; if([[hexTextView string] isEqualToString:@""]) { [editSheetProgressBar startAnimation:self]; if([sheetEditData isKindOfClass:[NSData class]]) { @@ -602,7 +624,7 @@ [panel beginSheetForDirectory:nil file:fileDefault - modalForWindow:[self window] + modalForWindow:usedSheet modalDelegate:self didEndSelector:@selector(savePanelDidEnd:returnCode:contextInfo:) contextInfo:NULL]; @@ -1191,7 +1213,7 @@ */ - (IBAction)bitSheetSelectBit0:(id)sender { - [[self window] makeFirstResponder:[self valueForKeyPath:@"bitSheetBitButton0"]]; + [usedSheet makeFirstResponder:[self valueForKeyPath:@"bitSheetBitButton0"]]; } /** |