2 SuperCollider real time audio synthesis system
3 Copyright (c) 2002 James McCartney. All rights reserved.
4 http://www.audiosynth.com
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #import "GetStringFromUser.h"
25 @implementation GetStringFromUser
27 static id sharedGetStringObject = nil;
29 + (id)sharedInstance {
30 if (!sharedGetStringObject) {
31 [[self allocWithZone:[[NSApplication sharedApplication] zone]] init];
33 return sharedGetStringObject;
37 if (sharedGetStringObject) {
39 return sharedGetStringObject;
42 if (!(self = [super init])) return nil;
46 sharedGetStringObject = self;
52 if (![NSBundle loadNibNamed:@"GetStringDlg" owner:self]) {
53 NSLog(@"Failed to load GetStringDlg.nib");
56 if (self == sharedGetStringObject) [[textField window] setFrameAutosaveName:@"GetString"];
58 [textField setStringValue: [self string]];
62 - (NSPanel *)getStringPanel
64 if (!textField) [self loadUI];
65 return (NSPanel *)[textField window];
73 - (void)setString:(NSString *)newString
75 if ([newString isEqualToString:string]) return;
77 string = [newString copyWithZone:[self zone]];
79 [textField setStringValue: string];
80 [textField selectText: nil];
85 - (void)setPrompt:(NSString *)newString
88 [promptField setStringValue: newString];
89 [promptField selectText: nil];
94 /* Action methods, sent from the find panel UI; can also be connected to menu items */
97 if (textField) [self setString: [textField stringValue]];
98 // lock the language VM and call some method..
101 - (void)cancel:(id)sender