I am refactoring the part of a project where I Open / Save the data under differenct file format. Using the example code shared in SaveAsDialog simplify both the User Interface and the code:
one master MenuItem only (both in the File Menu and in the code dispatching).
When I wanted to start to modify the OpenAsDialog err, no class with that name, only OpenDialog (read below).
So, it was late yesterday evening and I only create the methods to deal with the data (Method name and Parameters) and put the comments blocks with Method Names, Inputs / Outputs, Syntax and explanation about hat the code below will do, ect.) Then I fired EyeTV and watch TV the slept !
Then, when I woke up half an hour now
In the Category:Files Dialogs, there are 5 pages (Four Classes and one Method):
GetOpenFolderItem *
FolderItemDialog
OpenDialog
SaveAsDialog
SelectFolderDialog
At first look, there is a wrong: OpenDialog / SaveAsDialog and a missing: GetSaveFolderItem *.
While you are changing the Frameworks (so doing a lot of changes), you may add that simple change: rename OpenDialog to OpenAsDialog.
Back to the core of the question.
In SaveAsDialog, there is an example to how allow to add a PopupMenu with a file extension selector. OpenDialog does not have that example.
I woke up minutes ago with that crazy idea (already expressed here month ago) that if Save As can be implemented with this nice mechanism, why cant I do the same winth Open As ?
So, I took the example from SaveAsDialog and place it into an Open Event, change a bit the code and run it
OS X 10.9.5: no PopupMenu file extension selector
Windows XP: Yeah ! There it is: I got that File Extension selector (watch the screen shot).
OK: I know, different OS / Different implementatio n / code, and all that bullshit. BUT, getting a similar user interface on the platform is better, far better than all these small differences either for the coder and the user
Here is the relevant code:
[code] Dim dlg As New OpenDialog // Was: SaveAsDialog
Dim f As FolderItem
Dim txtType as New FileType
txtType.Name = “Text File (*.txt)”
txtType.MacType = “TEXT”
txtType.Extensions = “txt”
Dim htmlType As New FileType
htmlType.Name = “HTML File (*.htm, *.html)”
htmlType.MacType = "HTML "
htmlType.Extensions = “htm”
Dim csvType as New FileType
csvType.Name = “CSV File (*.csv)”
csvType.MacType = “TEXT”
csvType.Extensions = “csv”
Dim xlsType As New FileType
xlsType.Name = “Excel File (*.xls)”
xlsType.MacType = "XLS "
xlsType.Extensions = “xls”
#If Not (TargetLinux) then
dlg.InitialDirectory=SpecialFolder.Documents
#Else //open Home directory on linux
dlg.InitialDirectory=SpecialFolder.Home
#endif
dlg.Title = “Select a MIF file”
dlg.Filter = txtType + htmlType + csvType +xlsType // Was: FileTypes1.mif
f = dlg.ShowModal()
If f <> Nil then
//proceed normally
Else
//User Cancelled
End if[/code]
I added // Was: to mark the differences between that code and the original that lies in the SaveAsDialog Class.
Remember: it is far more user friendly to let the user choose ONE MenuItem (FileOpen or FileSave) and choose its file type to open/.save from txtType + htmlType + csvType + xlsType than search from:
File.OpenAsTXT
File.OpenAsHTML
File.OpenAsCSV
File.OpenAsXLS
and that is from there that I came to write this mail.
WINDOWS DEVELOPERS: did I told you lately that you already have this feature ? Watch carefully the screen shot.
- Talking about consistency, can someone check the Notes section of both GetOpenFolderItem and GetSaveFolderItem ?
Notably:
The GetOpenFolderItem function displays the standard open-file dialog box for the platform on which the application is running. The FolderItemDialog class has the same purpose but allows for some customization.
and
The GetSaveFolderItem function displays the standard Save As file dialog box, allowing the user to choose a location and enter a name for the file to be saved. The SaveAsDialog class provides the same functionality but allows for customization.
FolderItemDialog vs SaveAsDialog
Thank you for reading and sharing your fieeling on the subject.
OpenDialog on OS X 10.9.5:
OpenDialog on Windows XP:
Same code, Windows XP application: generated on OS X.