Using the code posted by WilliamL (originally Fred) in the Cocoa tips and tricks thread, I created a test app as such:
Code: Select all
ImportC ""
PB_Gadget_SetOpenFinderFiles(Callback)
EndImport
IsGadget(0) ; Ensures the gadget lib is linked as this command is in it
Procedure OpenFinderFilesCallback(*Utf8Files)
Protected filecnt,filesin$,filename$
filesin$ = PeekS(*Utf8Files, -1, #PB_UTF8) ; Each file is separated by a 'tab'
MessageRequester("",filesin$)
If Len(filesin$) ; Here you have the filename to open
MessageRequester("Raw Load...",filesin$+" filecount="+Str(CountString(filesin$,Chr(9)))) ; Use StringField() to iterate easily
For filecnt=1 To CountString(filesin$,Chr(9))+1
filename$=StringField(filesin$,filecnt,Chr(9))
filepath$=GetPathPart(filename$)
filename$=GetFilePart(filename$)
MessageRequester("Loading file...",filePath$+Chr(13)+filename$)
Next
EndIf
EndProcedure
OpenWindow(0, 0, 0, 300, 300, "Accept Files Test", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
PB_Gadget_SetOpenFinderFiles(@OpenFinderFilesCallback()); should be put very early in the code, before any event loop
;MessageRequester("Done","Done")
Repeat
Repeat
Select WindowEvent()
Case #PB_Event_CloseWindow
End
Case #Null
Break
EndSelect
ForEver
ForEver