Page 1 of 1
Oxygen API to detect close operation on file
Posted: Tue May 02, 2023 6:40 pm
by FrankDLT
Hello and good day.
I'm working on a project with the requirement of suggesting an action to the user upon trying to close a file in the editor, is there any API I could use that detects when a file was selected to close by the "X" button or the right click close option?
Thank you.
-Frank
Re: Oxygen API to detect close operation on file
Posted: Wed May 03, 2023 12:12 am
by FrankDLT
Hello team,
I while after I posted the question I came across the API for editorAboutToBeClosed() which is exactly what I was looking for.
But I did have another query, since I have the plugin workspace access is there a way to extract the name of the file its been worked on?
Thank you.
-Frank
Re: Oxygen API to detect close operation on file
Posted: Wed May 03, 2023 8:27 am
by Radu
Hi Frank,
The "editorAboutToBeClosed" callback receives the URL of the file which is about to be closed.
Regards,
Radu
Re: Oxygen API to detect close operation on file
Posted: Wed May 24, 2023 6:25 pm
by FrankDLT
Hi Radu
Thanks for your response, I have been testing the API that you suggested and works great.
I do have a question regarding the API, is it possible to detect only when the user clicks on the (X) or does a right click and selects "close" on the file?
Right now it is triggering the API when the file is closed by any reason such as closing oxygen itself and other methods that involve closing a file, but I only need it to trigger on direct closure of the file.
Thank you for your time and assistance,
Frank
Re: Oxygen API to detect close operation on file
Posted: Thu May 25, 2023 7:34 am
by Radu
Hi Frank,
We do not have particular API which would allow you to know "how" an end user decided to close a file.
We do have this callback that you receive in the plugin extension "ro.sync.exml.plugin.workspace.WorkspaceAccessPluginExtension.applicationClosing()" and which should notify you before the actual opened documents are closed so maybe you can use this to your advantage and on the "WorkspaceAccessPluginExtension.applicationClosing" callback remove for example the listener you have added to listen for editor closed notifications.
Regards,
Radu