Now Mac file dialogs work in a background thread
This commit is contained in:
@@ -41,7 +41,6 @@ class FileDialog {
|
||||
if (type == null) type = FileDialogType.OPEN;
|
||||
|
||||
#if desktop
|
||||
#if !mac
|
||||
|
||||
var worker = new BackgroundWorker ();
|
||||
|
||||
@@ -107,61 +106,6 @@ class FileDialog {
|
||||
|
||||
worker.run ();
|
||||
|
||||
#else
|
||||
|
||||
var path:String = null;
|
||||
var paths:Array<String> = null;
|
||||
|
||||
switch (type) {
|
||||
|
||||
case OPEN:
|
||||
|
||||
path = lime_file_dialog_open_file (filter, defaultPath);
|
||||
|
||||
case OPEN_DIRECTORY:
|
||||
|
||||
path = lime_file_dialog_open_directory (filter, defaultPath);
|
||||
|
||||
case OPEN_MULTIPLE:
|
||||
|
||||
paths = lime_file_dialog_open_files (filter, defaultPath);
|
||||
|
||||
case SAVE:
|
||||
|
||||
path = lime_file_dialog_save_file (filter, defaultPath);
|
||||
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
|
||||
case OPEN, OPEN_DIRECTORY, SAVE:
|
||||
|
||||
if (path != null) {
|
||||
|
||||
onSelect.dispatch (path);
|
||||
|
||||
} else {
|
||||
|
||||
onCancel.dispatch ();
|
||||
|
||||
}
|
||||
|
||||
case OPEN_MULTIPLE:
|
||||
|
||||
if (paths != null && paths.length > 0) {
|
||||
|
||||
onSelectMultiple.dispatch (paths);
|
||||
|
||||
} else {
|
||||
|
||||
onCancel.dispatch ();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#end
|
||||
|
||||
return true;
|
||||
|
||||
#else
|
||||
@@ -177,7 +121,6 @@ class FileDialog {
|
||||
public function open (filter:String = null, defaultPath:String = null):Bool {
|
||||
|
||||
#if desktop
|
||||
#if !mac
|
||||
|
||||
var worker = new BackgroundWorker ();
|
||||
|
||||
@@ -207,28 +150,6 @@ class FileDialog {
|
||||
|
||||
worker.run ();
|
||||
|
||||
#else
|
||||
|
||||
// Doesn't work in a thread
|
||||
|
||||
var path:String = lime_file_dialog_open_file (filter, defaultPath);
|
||||
|
||||
if (path != null) {
|
||||
|
||||
try {
|
||||
|
||||
var data = File.getBytes (path);
|
||||
onOpen.dispatch (data);
|
||||
return true;
|
||||
|
||||
} catch (e:Dynamic) {}
|
||||
|
||||
}
|
||||
|
||||
onCancel.dispatch ();
|
||||
|
||||
#end
|
||||
|
||||
return true;
|
||||
|
||||
#else
|
||||
@@ -244,7 +165,6 @@ class FileDialog {
|
||||
public function save (data:Resource, filter:String = null, defaultPath:String = null):Bool {
|
||||
|
||||
#if desktop
|
||||
#if !mac
|
||||
|
||||
var worker = new BackgroundWorker ();
|
||||
|
||||
@@ -274,26 +194,6 @@ class FileDialog {
|
||||
|
||||
worker.run ();
|
||||
|
||||
#else
|
||||
|
||||
var path:String = lime_file_dialog_save_file (filter, defaultPath);
|
||||
|
||||
if (path != null) {
|
||||
|
||||
try {
|
||||
|
||||
File.saveBytes (path, data);
|
||||
onSave.dispatch (path);
|
||||
return true;
|
||||
|
||||
} catch (e:Dynamic) {}
|
||||
|
||||
}
|
||||
|
||||
onCancel.dispatch ();
|
||||
|
||||
#end
|
||||
|
||||
return true;
|
||||
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user