How does 'Open with' work internally?

I have ported an application we use at work to show UBL/PePPoL documents. These are XML-based documents (mostly containing an embedded PDF). The application is developed in Lazarus.

It works fine when you open a document from the application itself, and when run from terminal when given the document as parameter, it works fine too.
However if I use ‘Open with’ popup menu, it opens the application, but without opening the document.

I’ve made a test app to see what parameters are passed on to the application, but as it seems, no parameter is added, so you have no clue what file was used with ‘Open with’.

How does the ‘Open with’-function work and how does it pass the needed data to the application?

screenshot1
screenshot2

2 Likes

This is probably what you want (edit, snd the wrong link) The Haiku Book: BApplication Class Reference

If this is a qt app it may need to be changed to support qts way to get args after app launch… but i forgot what that is called.

edit: wrong link should have been refs receiver

1 Like

Thanks.

It seems I will indeed need RefsReceived() to get the data needed.
I will have to search how (or if) this can be called from lazarus.

If it is a Qt5 app the best way would be if the application would be patched to support the FileOpen event, because that’s what RefsReceived is triggering.

The alternative is to set the QT:QPA_FLAGS attribute for the application to Q_REF_TO_ARGV, the Qt will attempt to convert the initial RefsReceived message into command line arguments.

See also my comment on

3 Likes

Found it. I needed to add the attributes to the executable using xres. Now it functions like it should.

@phw Thanks for pointing me to the right direction.

2 Likes

Looks like I’m not the only Belgium user here (hard to track them) :wink:
Groeten @zittergie vanuit Limburg :wink:

1 Like

@Begasus Groeten terug vanuit West-Vlaanderen.

1 Like