applicationDidBecomeActive from dock vs open document? - cocoa

When I receive applicationDidBecomeActive, is there a way to tell if it is because a document was double clicked in the Finder (or drug to the app icon), vs just having clicked on the Dock icon or selected the app with Cmd-Tab?
I need to know if applicationDidBecomeActive is associated with an openDocument event.

Related

macOS: How to detect when an application's finder icon has been opened?

When a macOS application is already open and running, is there any way for it to detect when its Finder icon is opened?
In that situation, opening its Finder icon causes the application to become active, and I can detect that event using NSNotificationCenter or the application delegate's applicationDidBecomeActive: method.
However, so far I haven't found a way to distinguish that activation event from any of the other ways an application can become active, such as clicking on its window, clicking on its Dock icon, switching to it using command+tab, activating it with AppleScript, and so on. I tried checking to see if any of these circumstances used an apple event to activate the app with [[NSAppleEventManager sharedAppleEventManager] currentAppleEvent], but it returns nil as there is no current apple event, so that doesn't help.
The app delegate method -applicationShouldHandleReopen:hasVisibleWindows: is called on such a re-open event.
Note that (re-)opening from the Finder, Launchpad, or Dock is the same, by design.

Always show Badge Count in OS X

Apple's own apps such as Reminders show Badge count even if they are not running or after quitting them
Other apps (some even with Helper apps) show badge when they are running, but it disappears as soon as you quit the application
is there a way, user side, or programming side, we can do to always show this badge, even when the app is not running?
I searched a lot in Google, didn't find anything about "always" showing this badge, maybe "badge count" is the wrong keyword
Yes, Create dock Tile Plug-in.
Starting in OS X v10.6, you can customize an application’s Dock tile
icon and menu when the application is not running.
When your application needs to customize the Dock tile, it manipulates the NSDockTile object that was provided to the initial call to the setDockTile: method.
To dynamically change the application's Dock icon, you can draw a Dock icon using a custom view. See Using a Custom View to Draw a Dock Icon.
To add text to a Dock icon, you can apply a badge label. See Changing the Text of a Badge Label.

Display NSPopover above dock icon

How can I display an NSPopover above my app's dock icon?
There are two ways to customise the dock menu, based on if your application is running or not. See the Apple documentation for customising it when its open here:
http://developer.apple.com/library/mac/#documentation/Carbon/Conceptual/customizing_docktile/docktasks_cocoa/docktasks_cocoa.html#//apple_ref/doc/uid/TP30000986-CH3-SW1
To summarise, you basically provide a menu in the main application's XIB or storyboard which contains the extra menu options that you want to add to the dock menu.
To customise your Dock icon's menu when the application is not running, see the guide here:
http://developer.apple.com/library/mac/#documentation/Carbon/Conceptual/customizing_docktile/CreatingaDockTilePlug-in/CreatingaDockTilePlug-in.html
Basically, you need to create a plugin which you drop into your application's resource folder. This works very like the original method, but executes inside Finder's dock process.

Where to find what commands/properties are available for AppleScript in Microsoft Outlook 2011

Does anyone know where I can find a list of available applescript commands/properties for Microsoft Outlook 2011?
I am trying to copy subject of the opened message into the clipboard and save the message as PDF to my desktop with subject as the file name.
Thanks.
All applications that are apple-scriptable have a "dictionary" of terms as part of the application itself. To access a dictionary open AppleScript Editor, under the File menu choose "open dictionary", and then choose the application.
A second way would be to drag/drop the application onto the AppleScript Editor icon in the dock or applications folder.
A third way... under the Window menu in AppleScript Editor choose "Library". That window is a quick-access tool to access the dictionaries of various applications. You can click the "+" button to add applications not in that list. Double-click an application in the list to access its dictionary.
A 4th way... if AppleScript Editor and the application you are interested in are both in the dock, you can command-drag the application's dock icon onto the AppleScript Editor's dock icon.

Hiding NSMenu while the dock remains active

I want my app to show his menu on launch only if the user didn't open a file. Now I can't seem to make it work. Hiding the menu makes the dock and the status bar invisible. I want them to still be there, but not with my own menu (e.g. if you open a file from finder, the finder menu is still visible, but my app opens a window that handles the file, and quits if the user cancels or on completion).
I probably didn't explain it well enough, but here's what I did to solve it :
Add this line to the plist of my app (this produces an app without dock icon or menu), the dock and the menu bar will still be there, but won't be changed by the app :
LSUIElement
(And set the checkbox to true).
This makes your app UI-only (it doesn't show his NSMenu nor does it add an icon to the dock, but just shows your GUI.

Resources