Is it possible to pass mouse events through an NSWindow to whatever is behind it (even if it is a window from another application)?
I am using NSWindow to create a desktop overlay, but would like to still be able to interact with other windows, even if they are behind my overlay window.
IIRC, you can just use [window setIgnoresMouseEvents:YES].
Related
NSPanel has a “Non activating” option for HUD Panels. I’d like to get that same functionality working on an NSWindow, i.e. I want the window to accept clicks but not take focus away from whatever the active app is (by this I mean the app that was active before clicking on the window activated my app—in this case Sketch).
I have tried creating an NSWindow subclass and setting canBecomeMainWindow and canBecomeKeyWindow to NO but that doesn’t seem to be working—I think because those settings only apply to windows within the same app.
What I’m trying to do here is prevent this flickering. I’m pretty sure this is doable as apps like Alfred seem to be doing it.
Is there any way to detect and respond when a control on a window loses focus?
I want to run some code when a user leaves NSTableView.
Thanks,
You can do this in 10.6 and later by using KVO to observe the window's firstResponder. It will change when the focused control in the window changes.
Put the code you want to run in the observing object's observeValueForKeyPath:ofObject:change:context: method.
When you drag to a dock icon and pause, all of that app's windows are brought to the front in an expose-like view. Dragging to those windows will outline the window in blue, but how do I get the window to actually accept the drop? What is being queried during this expose process?
I had thought that maybe it would be treated as a drop onto the NSWindow itself but this doesn't seem to be the case. (I can successfully drag and drop onto my windows when they are normally visible.)
What's is the equivalent of window's WM_MOVE in Mac OS ? I have to capture a mouse event when one moves window using left click. In windows we can capture this event using WM_MOVE but i could not find similar event in Mac OS
In Cocoa, look at the NSWindow and NSNotificationCenter classes (or alternately assign a delegate instance to an NSWindow, which receives notifications implicitly just by implementing appropriate methods).
For instance you can use windowWillMove: or windowDidMove: notifications to notice when a window has been moved by the user. This is not sent continuously; it is sent when the user starts moving a window, or pauses while moving the window. If you need fine-grained control over mouse events you can subclass the window and implement methods from its superclass NSResponder.
I'm trying to determine when an NSOpenPanel is closing before it actually closes. I need to do this so I can overlay another window with a screenshot of the open panel on top of it to be animated. Unfortunately, all the notifications that you seem to be able to access seem to fire AFTER the window's already been closed. This leads to a jarring stutter before you start your transition.
I've tried:
- using NSWindow delegate methods on the open panel (apparently, none of the NSWindow delegate methods work)
- monitoring panel:userEnteredFilename:confirmed: (not called)
- showing the dialog with a callback (callback happens AFTER the panel disappears)
You should register your controller as the open panel's delegate and then implement the -panel:isValidFilename: delegate method. This method will be called just before the open dialog closes.
You should return YES from the method if you just want the notification. Returning NO allows you to prevent the open dialog from being closed.
Another way to handle this was to look through NSOpenPanel's subviews for the Cancel button and swap yourself in as the target/action. This is what i ended up doing.