Page 1 of 1

Explorertreegadget

Posted: Sun Feb 28, 2016 9:30 am
by collectordave
Now taken the plunge and bought a MACBook Pro.

Looking at the explorer treegadge,t loaded the code from the help file and managed to get a blank gadget on screen.

Is there a default directory\folder for the MAC as on windows?

Asking as I wish to get my image file selector working on the MAC as well as windows.

Any help with code appreciated.

Regards

CD

Re: Explorertreegadget

Posted: Sun Feb 28, 2016 11:55 am
by Shardik
collectordave wrote:Looking at the explorer treegadge,t loaded the code from the help file and managed to get a blank gadget on screen.

Is there a default directory\folder for the MAC as on windows?
No, you have to supply at least "/" for the Directory$ parameter. The Windows example from help doesn't work and should be replaced by a working one in MacOS help.
collectordave wrote:Asking as I wish to get my image file selector working on the MAC as well as windows.
Unfortunately that's currently not possible. A pattern with file extensions doesn't work on MacOS. This should be documented in the MacOS help for ExplorerTreeGadget() and ExplorerListGadget() like it is documented for the OpenFileRequester():
[color=#0040FF]MacOS help for OpenFileRequester[/color] wrote:Several extensions can be specified for a single type by using the ; (semi-colon) separator (not supported on OSX, the requester always displays all files).
An alternative to the ExplorerTreeGadget for MacOS would be to use an NSOpenPanel. Wilbert already demonstrated in this example code how to let the user choose files with predefined file extensions although ALL files will be visible. But the files with the predefined extensions are the only ones the user will be able to select...

Re: Explorertreegadget

Posted: Tue Mar 01, 2016 6:08 am
by collectordave
Thanks Shardik

The start folder I have managed a get around by using an application global constant dependant on OS which with #PBnofiles gets me what I want.

Code on forum updated http://www.purebasic.fr/english/viewtop ... +module%3A

Regards

CD

Re: Explorertreegadget

Posted: Tue Mar 01, 2016 11:37 am
by Shardik
You don't need to use CompilerIfs to display the root folder for Linux, MacOS and Windows. The slash ("/" ) works cross-plattform on all 3 platforms. I thus modified the code example from help to work cross-platform (without the file extension patterns which don't work on MacOS):

Code: Select all

If OpenWindow(0, 0, 0, 300, 300, "ExplorerTreeGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ExplorerTreeGadget(0, 10, 10, 280, 280, "/")
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Alternatively you may use GetHomeDirectory() or GetTemporaryDirectory() which of course also work cross-platform... :wink: