A rather simple question for which I did not find any answer. I have implemented an Exit menu item linked to a command that invokes an exit handler, and I would like this handler to be invoked when the user closes the workbench (top-right X button of the workbench) too.
The first part is simple: You need to register a IWindowCloseHandler to the context of your window.
The second part isn't that simple. It's about the when to put your implementation to the context. It is not possible within a lifecycle hook as this is renderer specific for the window, and therefore the MWindow doesn't exist at that time. Therefore you need to do some kind of workaround to achieve this. I solved it in my projects by doing this the first time a part is created that is always visible within my app. So it shouldn't be called twice.