Reputation: 873
I have a window that I want users to be able to move by dragging anywhere in the window content (not just the titlebar). I know that this can be done via the NSWindow movableByWindowBackground
method, however this doesn't appear to work by itself.
I gather that overriding NSView mouseDownCanMoveWindow
may be necessary. But I can't easily do that for all parent views (split views, etc). Making it a textured window didn't help. Unsurprisingly, subclassing NSWindow
to override isMovableByWindowBackground
didn't help either.
Is it really necessary to subclass all parent views in the window to make this work?
Upvotes: 8
Views: 2099
Reputation: 119
In NSSplitView you add:
override var mouseDownCanMoveWindow: Bool {
return true
}
Upvotes: 1
Reputation: 2792
On OS X 10.11, setting the NSWindow's property movableByWindowBackground
to YES
works.
There is no longer any need to subclass for this behaviour.
Upvotes: 7