waneck / systools

fork of neko-systools ( https://code.google.com/p/neko-systools ) for Haxe 3/Neko 2
Other
49 stars 21 forks source link

Open File Dialogue bug [Fixed] #21

Closed BluFedora closed 6 years ago

BluFedora commented 9 years ago

How would I test to see if the dialogue was canceled ? if the dialogue is canceled then it will crash

var result = Dialogs.openFile ( "Select a Map File", "Test Message", filter );

// I Tried This if (result.length > 0) { trace(result[0]); }

// I've also tried this if (result != null || result != "") { trace(result[0]); }

This just crashes the program. Is there a way to see/handle a canceled open dialogue ? thanks if someone can help -Blufedora

Tiago-Ling commented 9 years ago

I'm using the openFile command without any problem in Windows.

Try this:

var result = Dialogs.openFile(...);
if (result != null) {
    trace(result);    //Will return an Array<String> of file paths
    //Do anything with the filepaths returned
}

In your last try there is an error in assuming that result is a String.