make find panel more consistent with other cocoa apps (bug 160771)
git-svn-id: svn://10.0.0.236/trunk@149256 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
8028cb4271
commit
c7c52ea1cc
@ -41,13 +41,16 @@
|
|||||||
IBOutlet NSTextField* mSearchField;
|
IBOutlet NSTextField* mSearchField;
|
||||||
IBOutlet NSButton* mIgnoreCaseBox;
|
IBOutlet NSButton* mIgnoreCaseBox;
|
||||||
IBOutlet NSButton* mWrapAroundBox;
|
IBOutlet NSButton* mWrapAroundBox;
|
||||||
IBOutlet NSButton* mSearchBackwardsBox;
|
IBOutlet NSButton* mFindNextButton;
|
||||||
IBOutlet NSButton* mFindButton;
|
IBOutlet NSButton* mFindPrevButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction) find: (id)aSender;
|
- (IBAction) findNextButton: (id)aSender;
|
||||||
|
- (IBAction) findPreviousButton: (id)aSender;
|
||||||
|
- (IBAction) findNextAndOrderOut: (id)aSender;
|
||||||
|
|
||||||
// delegates for NSTextView
|
// delegates for NSTextView
|
||||||
- (void)controlTextDidChange:(NSNotification *)aNotification;
|
- (void)controlTextDidChange:(NSNotification *)aNotification;
|
||||||
|
- (void)loadFindStringFromPasteboard;
|
||||||
|
- (void)putFindStringOnPasteboard;
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -39,75 +39,121 @@
|
|||||||
#import "Find.h"
|
#import "Find.h"
|
||||||
|
|
||||||
@interface FindDlgController(Private)
|
@interface FindDlgController(Private)
|
||||||
- (NSString*)getSearchText;
|
- (NSString*)getSearchText;
|
||||||
|
- (BOOL)find:(BOOL)searchBack;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation FindDlgController
|
@implementation FindDlgController
|
||||||
|
|
||||||
|
- (void)loadFindStringFromPasteboard
|
||||||
|
{
|
||||||
|
NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSFindPboard];
|
||||||
|
if ([[pasteboard types] containsObject:NSStringPboardType]) {
|
||||||
|
NSString *string = [pasteboard stringForType:NSStringPboardType];
|
||||||
|
if (string && [string length]) {
|
||||||
|
[mSearchField setStringValue: string];
|
||||||
|
[mFindNextButton setEnabled:YES];
|
||||||
|
[mFindPrevButton setEnabled:YES];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)putFindStringOnPasteboard
|
||||||
|
{
|
||||||
|
NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSFindPboard];
|
||||||
|
[pasteboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
|
||||||
|
[pasteboard setString:[mSearchField stringValue] forType:NSStringPboardType];
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// -find
|
// -find
|
||||||
//
|
//
|
||||||
// User clicked the find button, send the action to the window controller of the
|
// Performs the actual search. returns YES on success.
|
||||||
// frontmost browser window. If we found something, hide the window. If not, beep.
|
|
||||||
//
|
//
|
||||||
-(IBAction) find: (id)aSender
|
|
||||||
|
-(BOOL) find:(BOOL)searchBack
|
||||||
{
|
{
|
||||||
NSWindowController* controller = [[NSApp mainWindow] windowController];
|
NSWindowController* controller = [[NSApp mainWindow] windowController];
|
||||||
if ( [controller conformsToProtocol:@protocol(Find)] ) {
|
if ( [controller conformsToProtocol:@protocol(Find)] ) {
|
||||||
id<Find> browserController = controller;
|
id<Find> browserController = controller;
|
||||||
BOOL ignoreCase = [mIgnoreCaseBox state];
|
BOOL ignoreCase = [mIgnoreCaseBox state];
|
||||||
BOOL wrapSearch = [mWrapAroundBox state];
|
BOOL wrapSearch = [mWrapAroundBox state];
|
||||||
BOOL searchBack = [mSearchBackwardsBox state];
|
return [browserController findInPageWithPattern:[mSearchField stringValue] caseSensitive:!ignoreCase wrap:wrapSearch backwards:searchBack];
|
||||||
|
|
||||||
BOOL found = [browserController findInPageWithPattern:[mSearchField stringValue]
|
|
||||||
caseSensitive:!ignoreCase wrap:wrapSearch
|
|
||||||
backwards:searchBack];
|
|
||||||
|
|
||||||
if (! found )
|
|
||||||
NSBeep();
|
|
||||||
// we stay open
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IBAction) findNextButton: (id)aSender
|
||||||
|
{
|
||||||
|
[self putFindStringOnPasteboard];
|
||||||
|
if (![self find:NO])
|
||||||
NSBeep();
|
NSBeep();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (IBAction) findPreviousButton: (id)aSender
|
||||||
|
{
|
||||||
|
[self putFindStringOnPasteboard];
|
||||||
|
if (![self find:YES])
|
||||||
|
NSBeep();
|
||||||
|
}
|
||||||
|
|
||||||
|
- (IBAction) findNextAndOrderOut: (id)aSender
|
||||||
|
{
|
||||||
|
[self putFindStringOnPasteboard];
|
||||||
|
if (![self find:NO])
|
||||||
|
NSBeep();
|
||||||
|
else
|
||||||
|
[self close];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// controlTextDidChange
|
// -controlTextDidChange:
|
||||||
//
|
//
|
||||||
// Check if there is anything in the text field, and if not, disable the find button
|
// Check if there is anything in the text field, and if not, disable the find button
|
||||||
//
|
//
|
||||||
- (void)controlTextDidChange:(NSNotification *)aNotification
|
- (void)controlTextDidChange:(NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
if ( [[mSearchField stringValue] length] )
|
if ( [[mSearchField stringValue] length] ) {
|
||||||
[mFindButton setEnabled:YES];
|
[mFindNextButton setEnabled:YES];
|
||||||
else
|
[mFindPrevButton setEnabled:YES];
|
||||||
[mFindButton setEnabled:NO];
|
}
|
||||||
|
else {
|
||||||
|
[mFindNextButton setEnabled:NO];
|
||||||
|
[mFindPrevButton setEnabled:NO];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// -getSearchText
|
||||||
|
//
|
||||||
// Retrieve the most recent search string
|
// Retrieve the most recent search string
|
||||||
|
//
|
||||||
- (NSString*)getSearchText
|
- (NSString*)getSearchText
|
||||||
{
|
{
|
||||||
NSWindowController* controller = [[NSApp mainWindow] windowController];
|
NSPasteboard *findPboard = [NSPasteboard pasteboardWithName:NSFindPboard];
|
||||||
if (![controller conformsToProtocol:@protocol(Find)])
|
if ([[findPboard types] indexOfObject:NSStringPboardType] != NSNotFound)
|
||||||
return nil;
|
return [findPboard stringForType:NSStringPboardType];
|
||||||
|
|
||||||
id<Find> browserController = controller;
|
return [NSString string];
|
||||||
return [browserController lastFindText];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// -showWindow:
|
||||||
|
//
|
||||||
|
// override to set the current search text in the text area before showing
|
||||||
|
// the window
|
||||||
|
//
|
||||||
- (IBAction)showWindow:(id)sender
|
- (IBAction)showWindow:(id)sender
|
||||||
{
|
{
|
||||||
// Sync our text field with the most recent browser search string.
|
[mSearchField setStringValue:[self getSearchText]];
|
||||||
// We assume here that the frontmost window is a browser window.
|
|
||||||
|
|
||||||
NSWindowController* controller = [[NSApp mainWindow] windowController];
|
|
||||||
if ( [controller conformsToProtocol:@protocol(Find)] ) {
|
|
||||||
id<Find> browserController = controller;
|
|
||||||
[mSearchField setStringValue:[browserController lastFindText]];
|
|
||||||
}
|
|
||||||
|
|
||||||
[super showWindow:sender];
|
[super showWindow:sender];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void)windowDidLoad
|
||||||
|
{
|
||||||
|
[mSearchField setStringValue:[self getSearchText]];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
IBClasses = (
|
IBClasses = (
|
||||||
{
|
{
|
||||||
ACTIONS = {find = id; };
|
ACTIONS = {findNextAndOrderOut = id; findNextButton = id; findPreviousButton = id; };
|
||||||
CLASS = FindDlgController;
|
CLASS = FindDlgController;
|
||||||
LANGUAGE = ObjC;
|
LANGUAGE = ObjC;
|
||||||
OUTLETS = {
|
OUTLETS = {
|
||||||
mFindButton = NSButton;
|
mFindNextButton = NSButton;
|
||||||
|
mFindPrevButton = NSButton;
|
||||||
mIgnoreCaseBox = NSButton;
|
mIgnoreCaseBox = NSButton;
|
||||||
mSearchBackwardsBox = NSButton;
|
|
||||||
mSearchField = NSTextField;
|
mSearchField = NSTextField;
|
||||||
mWrapAroundBox = NSButton;
|
mWrapAroundBox = NSButton;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,12 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="0.9">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>IBDocumentLocation</key>
|
<key>IBDocumentLocation</key>
|
||||||
<string>180 86 356 240 0 0 1152 746 </string>
|
<string>178 292 356 240 0 0 1152 848 </string>
|
||||||
<key>IBFramework Version</key>
|
<key>IBFramework Version</key>
|
||||||
<string>248.0</string>
|
<string>349.0</string>
|
||||||
|
<key>IBOpenObjects</key>
|
||||||
|
<array>
|
||||||
|
<integer>5</integer>
|
||||||
|
</array>
|
||||||
<key>IBSystem Version</key>
|
<key>IBSystem Version</key>
|
||||||
<string>5S66</string>
|
<string>7B85</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user