1

I have a mac os x app with a window which can be hidden.

When the user clicks on the app icon in the dock (or open -b com.mycompany.myapp in the terminal), I would like this window to be shown again (it's a Qt app, so the setVisible(true) thing is known).

How do I catch the app activation event?

Thanks for any help.

moala
  • 5,094
  • 9
  • 45
  • 66
  • 1
    This question is a duplicate of [Trap click event on dock icon using Qt on Mac](http://stackoverflow.com/questions/3767559/trap-click-event-on-dock-icon-using-qt-on-mac). – 0xced Aug 04 '11 at 13:50
  • @0xced: thanks for the link, I'll check that. – moala Aug 04 '11 at 14:15

1 Answers1

3

It's an Apple Event, so you'll want to use the Apple Event Manager to register a handler for the core suite's reopen-application event.

That's how you do it in Carbon. You tagged the question as [carbon] and not [qt], so I assume you want a Carbon solution rather than a Qt solution.

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
  • A Qt solution would also be nice :) – moala Aug 04 '11 at 15:48
  • Here is an howto for your AE solution: http://th30z.blogspot.com/2008/08/qt4-mac-dock-icon-click_2711.html – moala Aug 04 '11 at 16:23
  • Hi, any way to detect if a titlebar less app is minimized through custom handling (basically just hiding it), and then clicked in launchpad? I can get a handler if the dock icon is clicked, I need to get a similar notification when the app is hidden (minimized) and the launchpad icon/Applications folder icon is clicked as well so that I can unhide it.. – SexyBeast Jan 12 '16 at 06:40
  • @AttitudeMonger: Apps and windows are two different things. You can check whether your window is borderless by looking at its `styleMask`. You can do this in your reopen handler—Launchpad, AFAIK, doesn't do anything different from double-clicking your app in the Finder or clicking on it in the Dock. – Peter Hosey Jun 10 '16 at 05:39