MacOS: Get Filename from "document interaction controller"
MacOS: Get Filename from "document interaction controller"
Hi Fred and Team,
If a PB application handles a mime-type or file extension on MacOS, it gets startet after double clicking such a document. Sadly, the filename is not submitted as a commandline parameter. It is done using a document interaction controller. It is described here:
http://developer.apple.com/library/ios/ ... Types.html
Can you please check these UIApplicationLaunchOptionsURLKey values on executable start in MacOS and pass them as commandline parameters?
With this function the filename(s) from this interface will be usable with the ProgramParameter() function.
Thank you!
Kukulkan
If a PB application handles a mime-type or file extension on MacOS, it gets startet after double clicking such a document. Sadly, the filename is not submitted as a commandline parameter. It is done using a document interaction controller. It is described here:
http://developer.apple.com/library/ios/ ... Types.html
Can you please check these UIApplicationLaunchOptionsURLKey values on executable start in MacOS and pass them as commandline parameters?
With this function the filename(s) from this interface will be usable with the ProgramParameter() function.
Thank you!
Kukulkan
Re: MacOS: Get Filename from "document interaction controlle
You are mixing things up Kukulkan.
This is for the mobile operating system iOS only.
If you look at the title of the link you posted, you will see it mentions iOS.
This is for the mobile operating system iOS only.
If you look at the title of the link you posted, you will see it mentions iOS.
Re: MacOS: Get Filename from "document interaction controlle
Oh damn, you are right!
Anyway, we need a way to get the submitted filename. It is definitely NOT submitted as commandline parameter.
Any ideas around this issue? Or is this a PB bug only?
Kukulkan

Anyway, we need a way to get the submitted filename. It is definitely NOT submitted as commandline parameter.
Any ideas around this issue? Or is this a PB bug only?
Kukulkan
Re: MacOS: Get Filename from "document interaction controlle
You are right about the commandline parameter.
As for a workaround, I prefer to wait for a response from the PB team first.
All possible workarounds are not easy to accomplish. Maybe there's some simple solution I overlooked.
As for a workaround, I prefer to wait for a response from the PB team first.
All possible workarounds are not easy to accomplish. Maybe there's some simple solution I overlooked.
Re: MacOS: Get Filename from "document interaction controlle
I found this page:
https://developer.apple.com/library/mac ... rence.html
The arguments parameter should return this values...
Kukulkan
https://developer.apple.com/library/mac ... rence.html
The arguments parameter should return this values...
Kukulkan
Re: MacOS: Get Filename from "document interaction controlle
I already had looked into that but it just mentions the application name itself, no documents the application has to open unfortunately.
Re: MacOS: Get Filename from "document interaction controlle
Actually it was needed for IDE as well, so we did a quick hack. You can use it as well for now, it will probably change for something more integrated later (like using ProgramParameter() instead). As i'm away from home and don't have OS X, i can't test the following code but you get the idea:
Code: Select all
ImportC ""
PB_Gadget_SetOpenFinderFiles(Callback)
EndImport
IsGadget(0) ; Ensures the gadget lib is linked as this command is in it
ProcedureC OpenFinderFilesCallback(*Utf8Files)
Files$ = PeekS(*Utf8Files, #PB_Utf8) ; Each file is separated by a 'tab'
Debug Files$ ; Use StringField() to iterate easily
EndProcedure
PB_Gadget_SetOpenFinderFiles(@OpenFinderFilesCallback()) ; should be put very early in the code, before any event loop
Re: MacOS: Get Filename from "document interaction controlle
That's a much easier approach as other possible workarounds
The code form Fred is almost working except for the PeekS command

The code form Fred is almost working except for the PeekS command
Code: Select all
ImportC ""
PB_Gadget_SetOpenFinderFiles(Callback)
EndImport
IsGadget(0) ; Ensures the gadget lib is linked as this command is in it
ProcedureC OpenFinderFilesCallback(*Utf8Files)
Files$ = PeekS(*Utf8Files, -1, #PB_UTF8) ; Each file is separated by a 'tab'
MessageRequester("", Files$) ; Use StringField() to iterate easily
EndProcedure
PB_Gadget_SetOpenFinderFiles(@OpenFinderFilesCallback()) ; should be put very early in the code, before any event loop
Re: MacOS: Get Filename from "document interaction controlle
Hello,
this works fine if the app was called with a filename. But how to detect if it was called without a filename?
My application works both as viewer (filename in parameter) or editor (no filename).
If I like to view a file it works good with this hack. But if, with opened viewer, someone likes to run the editor (start app in "Applications"), it only activates my current viewer. The callback here is not called in this case (there is no filename given).
Any idea? Is there a callback like PB_Gadget_SetOpenFinderFiles() for this case, too?
Kukulkan
this works fine if the app was called with a filename. But how to detect if it was called without a filename?
My application works both as viewer (filename in parameter) or editor (no filename).
If I like to view a file it works good with this hack. But if, with opened viewer, someone likes to run the editor (start app in "Applications"), it only activates my current viewer. The callback here is not called in this case (there is no filename given).
Any idea? Is there a callback like PB_Gadget_SetOpenFinderFiles() for this case, too?
Kukulkan
Re: MacOS: Get Filename from "document interaction controlle
Hi Fred! You said a quick hack - is it still safe to use it?Fred wrote:Actually it was needed for IDE as well, so we did a quick hack. You can use it as well for now, it will probably change for something more integrated later (like using ProgramParameter() instead). As i'm away from home and don't have OS X, i can't test the following code but you get the idea:
Code: Select all
ImportC "" PB_Gadget_SetOpenFinderFiles(Callback) EndImport IsGadget(0) ; Ensures the gadget lib is linked as this command is in it ProcedureC OpenFinderFilesCallback(*Utf8Files) Files$ = PeekS(*Utf8Files, #PB_Utf8) ; Each file is separated by a 'tab' Debug Files$ ; Use StringField() to iterate easily EndProcedure PB_Gadget_SetOpenFinderFiles(@OpenFinderFilesCallback()) ; should be put very early in the code, before any event loop
For my own education is PB_Gadget_SetOpenFinderFiles hooking AEOpenDocuments from OS-X?
Thank you!