2 classvar result, ok, cancel;
5 OnError.add({ this.clear })
8 *getPaths { arg okFunc, cancelFunc, allowsMultiple=true;
10 "A CocoaDialog is already in progress. do: [CocoaDialog.clear]".warn;
14 //result = Array.new(maxSize);
17 this.prGetPathsDialog(allowsMultiple);
20 *openPanel { arg okFunc, cancelFunc, multipleSelection=false;
22 "A CocoaDialog is already in progress. do: [CocoaDialog.clear]".warn;
26 //result = Array.new(maxSize);
27 ok = if(multipleSelection){okFunc}{ {|res| okFunc.value(res[0])} };
29 this.prGetPathsDialog(multipleSelection);
32 *prGetPathsDialog { arg allowsMultiple;
36 *savePanel { arg okFunc,cancelFunc;
38 "A CocoaDialog is already in progress. do: [CocoaDialog.clear]".warn;
41 result = String.new(512);
44 this.prSavePanel(result);
46 *prSavePanel { arg argResult;
54 cancel = result = nil;
67 "An error has occured during a CocoaDialog".error;
69 *clear { // in case of errors, invalidate any previous dialogs
70 ok = cancel = result = nil;
76 *getPathsInDirectory { arg directoryPath,extension,maxItems=1000;
77 ^this.prGetPathsInDirectory(directoryPath,extension,Array.new(maxItems));
78 //throws an index out of range if more than maxItems items are in the directory
80 //extension matching not yet implemented
82 *prGetPathsInDirectory { arg dir,ext,arr;
83 _Cocoa_GetPathsInDirectory;