Dock icon opens window?

Howdy Doody,
If the user closes my main window, the app stays open as an NSStatusItem.

Is it possible to somehow re-open the main window when the user clicks on the dock icon?
At the moment - if they click on the dock item, the menubar appears but the main window remains closed.

Thanks.

[quote=107078:@Richard Summers]
If the user closes my main window, the app stays open as an NSStatusItem.

Is it possible to somehow re-open the main window when the user clicks on the dock icon?
At the moment - if they click on the dock item, the menubar appears but the main window remains closed.[/quote]

Use the App.HandleAppleEvent with eventID “rapp”

Michel - I have added the event handler to the app, but where do I enter the eventID “rapp”?
In the inspector I can only enter a description?

Thanks.

[quote=107102:@Richard Summers]Michel - I have added the event handler to the app, but where do I enter the eventID “rapp”?
In the inspector I can only enter a description?[/quote]

In the event handler, check if the variable eventID available there is “rapp” and do whatever is needed to display your window :slight_smile:

a simpler approach might be to check the app.activate event.

Then open your window there if it fires when you click the dock icon

[quote=107130:@Steve Upton]a simpler approach might be to check the app.activate event.

Then open your window there if it fires when you click the dock icon[/quote]

Nope. It does not suffice. I happen at this time to be working on an app where the dock icon opens a window. When the app has lost focus, App.Activate works fine. But when the app is already active, only App.HandleAppEvent fires when the icon is clicked.

Michel - I do not understand that at all :frowning:
Where / how do I check the variable eventID?

[quote=107138:@Richard Summers]Michel - I do not understand that at all :frowning:
Where / how do I check the variable eventID?[/quote]

Richard… It is always a good idea when you start using an event to check which variables it provides.

http://documentation.xojo.com/index.php/Application.HandleAppleEvent

EventID is one of the special variables available in the event to report about what triggered it. The “rapp” EventID says “reopen happened”, in other words the user clicked on the icon when the app was already active.

I have already looked at that - and didn’t understand 1 word of it???
Never mind - I will forget this idea, far too complex for me at the moment.

Thanks for trying to help :slight_smile:

[quote=107144:@Richard Summers]I have already looked at that - and didn’t understand 1 word of it???
Never mind - I will forget this idea, far too complex for me at the moment.
[/quote]

EventID is a string that can have diverse values depending on what happens to your app related to Apple events. Just check if EventID = "rapp" before popping up your window. How is it too complex for you ?

Michel - I was looking for some kind of setting in the inspector area called eventID, that’s why it made no sense.
I now realise you were referring to actual code to put into the event handler.

Duhhhhhhhh
All works fine now - THANK YOU :slight_smile: