Problems with Application.OpenDocument

I have an application where I created the event method “OpenDocument”
In this method there is only a MessageBox (just to check when it is called).
I click on a file that opens the application and it is really opened. Up to here, no problem.
But the Message is not shown what means that the method is never called,
However if I put in my application the line “OpenDocument new FolderItem”, then the Message is shown.

On the Xojo Documentation I can read:
“The user has double-clicked on a document which this app is specified to open or the OpenDocument method was called.”
But according to this experience only the second case is true.

Is it a bug or am I doing something wrong.
Thanks for any help.

Is your file type set up correctly? You need to have an identifier, a Role and a Rank:

Setting up file types until they work sucks majorly.

Ramon says the app is actually launched when he double-clicks the file, so the file type is apparently correct.
But why would the event not be called…?

Ramon, is that on Mac or Windows? If on Mac, you can check whether you get an AppleEvent when you double-click the file (in the HandleAppleEvent event of the app class).

Thanks a lot for your comments.
Yes, sorry, I forgot to say that I’m using Xojo 2021r3.1 on Windows 11
Beatrix, theoretically the file type is set by the installer. I hope it is well defined because as Arnaud says the application is opened when I double-click on the file and I looked in the Registry and there there is the order to open this file with that application.

Most probably this bug is related with the fact that this event has changed its name in the new API 2.0
Now it is called “DocumentOpened”.
I have not checked if this event woks properly, because my application is older and uses the old API

<https://xojo.com/issue/67462>

Finally I found the error.
It’s been hard because it is not a Xojo error.
Due to an unknown reason (it doesn’t matter now) my Registry was not correct. So it is only a Windows problem that doesn’t concern people using another OS.
In the FileType/Shell/Open/Command Registry item, the last “%1” was missing. Due to that, double-clicking the file opened the application but the file itself was not loaded.
And there was no message in Xojo saying that the file was missing.
Besides it is difficult to know when the event is raised. I thought that it was during the App.Open event, but it isn’t.
I put a break in the event method and used the System.DebugLog and it seems that the event is raised after the main window is opened, but I am not sure.
Anyway, I write this note just in case someone, someday, has the same problem.

1 Like