views:

657

answers:

2

Normal OSX applications eat the first mouse click when not focused to first focus the application. Then future clicks are processed by the application. iTunes play/pause button and Finder behave differently, the first click is acted on even when not focused. I am looking for a way to force an existing application (Remote Desktop Connection.app) to act on the first click and not just focus.

+1  A: 

Responding to the first mouse click when not focused is called 'click through'. And its worth is debated heatedly, for instance here and here.

Hans Sjunnesson
+5  A: 

Check NSView's acceptsFirstMouse, it may be what you're looking for.

acceptsFirstMouse: Overridden by subclasses to return YES if the receiver should be sent a mouseDown: message for an initial mouse-down event, NO if not.

  • (BOOL)acceptsFirstMouse:(NSEvent *)theEvent

Parameters theEvent The initial mouse-down event, which must be over the receiver in its window.

Discussion The receiver can either return a value unconditionally or use the location of theEvent to determine whether or not it wants the event. The default implementation ignores theEvent and returns NO.

Override this method in a subclass to allow instances to respond to click-through. This allows the user to click on a view in an inactive window, activating the view with one click, instead of clicking first to make the window active and then clicking the view. Most view objects refuse a click-through attempt, so the event simply activates the window. Many control objects, however, such as instances of NSButton and NSSlider, do accept them, so the user can immediately manipulate the control without having to release the mouse button.

somegeekintn