Calling NSApplication.requestUserAttention?

Archives Forums/MacOS X Discussion/Calling NSApplication.requestUserAttention?

Blueapples(Posted 2010) [#1]
Does anyone know how to call requestUserAttention? (http://developer.apple.com/Mac/library/documentation/Cocoa/Reference/ApplicationKit/Classes/NSApplication_Class/Reference/Reference.html#//apple_ref/occ/instm/NSApplication/requestUserAttention:)

I'd like to send a NSInformationalRequest notification to get the dock icon to bounce. I've done declares in Windows but a couple years back switched almost exclusively to Mac OS -- but I don't know how to make external calls like this. Seems like it probably isn't quite possible to just call the method since I'd need an actual NSApplication object. Anyone done this sort of thing in the past?


Brucey(Posted 2010) [#2]
There's a SharedApplication thing you can retrieve, which returns the current application instance.
In theory you could then use that to call your user-attention function.

Or perhaps that cocoa-module (by d-bug, maybe?) has support for that. Not sure if that also adds MaxGUI requirement or is standalone (one would hope so).


d-bug(Posted 2010) [#3]
Yep, cocoaext has support for it: http://www.chaos-interactive.de/en/cocoaext/ (Sorry, Brucey, it has heavy dependcies on MaxGUI)

'bounce once:
CocoaRequestUserAttention()

'or bounce until the user activated the application:
CocoaRequestUserAttention(True)


Keep in mind, that the application has to be suspended if you want to request user attention.