NSView outside NSWindow

I have an NSWindow and basically what I'm trying to do is open the NSWindow outside the bounds of the NSWindow every time the user hovers over the NSWindow.

But every time I try to do this because the NSView is outside the NSWindow it gets disconnected.

Here is a picture of what I am trying to achieve: enter image description here

+3


source to share


2 answers


You need to create a borderless NSWindow

one big enough to contain your view, and make the window a child of the main window it is anchored to. To make a window a child of another window, you use the addChildWindow:ordered:

NSWindow

.

child windows are attached to the parent window and will move with their parent window when the parent window is moved. If you just open a new window without making it a child window, it will be "left behind" if the other window is moved.



To create a borderless window, go NSBorderlessWindowMask

as styleMask

to method initWithContentRect:styleMask:backing:defer:

NSWindow

.

+6


source


The easiest way is to create another one NSWindow

without a border and place a button in it.



+2


source







All Articles