Directory selector problem (file object)
With the file object's save/load file selectors, I can know if the user clicked OK or Cancel by checking if the returned path name is empty or not.
With the directory selector, if you select a directory and then press Cancel, the path to this directory is still retrieved. How can I know if the user pressed Cancel or not?
Re: Directory selector problem (file object)
--Button Pressed
+Set Global Value A to 1
+Open Directory Selector
--FileSelReturn = ""
--Global Value = 1
--Only one action when event loops
The user chose cancel
--FileSelReturn <> ""
--Global Value = 1
--Only one action when event loops
The user chose a directory
Stephen1980
Re: Directory selector problem (file object)
Quote:
Originally Posted by Nifflas
With the directory selector, if you select a directory and then press Cancel, the path to this directory is still retrieved. How can I know if the user pressed Cancel or not?
Re: Directory selector problem (file object)
I just tried this. It works fine for me. I selected a directory and pressed cancel. FileSelReturn$( "File" ) was empty.
Re: Directory selector problem (file object)
Are you sure about that?
http://www.LB-Stuff.com/MMF2/FileDirectory.zip
Press D then hit cancel.
Re: Directory selector problem (file object)
Aha! It doesn't return the directory you selected. It returns the default pathname you entered!
Edit: I figured out a workaround. You can take advantage of the fact that FileSelReturn$( "File" ) never ends with a slash "\". So add a slash to your default pathname, the file object will accept this, but will not return the ending slash if you press cancel.
An example: Use as default pathname "D:\My Documents\"
If the user selects the My Documents folder, it will return "D:\My Documents"
If the user presses cancel "D:\My Documents\"
So all you need to do is check if left$(FileSelReturn$( "File" ),1)!="\"
Re: Directory selector problem (file object)
Yep! Hernan that's it! Awesome, looks like Nifflas will not have to use the Common Dialogues Obejct after all! :D
Thanks for finding the solution, Hernan!
Re: Directory selector problem (file object)
Hmm... sounds like a bug, don't use workarounds like that, that might not work on other versions of Windows or future versions of MMF2. I'm going to fix it in the release version of the build 249.
Re: Directory selector problem (file object)
Well that's even better :D
Re: Directory selector problem (file object)
Also, in your workaround, shouldn't you be testing for right$(FileSelReturn$("File"),1)!="\"?
Else you are looking at the start
Re: Directory selector problem (file object)
How about a condition that says that the cancel button was pressed? Then we dont' have to do anything fancy to get a simlple answer.
Steve
Re: Directory selector problem (file object)
Quote:
Originally Posted by Yves
Hmm... sounds like a bug, don't use workarounds like that, that might not work on other versions of Windows or future versions of MMF2. I'm going to fix it in the release version of the build 249.
All for that! :D