pbx
pbx

Reputation: 1137

Drawing outside of NSWindow

I understand how to draw inside an NSWindow frame. But I don't understand how to achieve something like this for example:

Taken from a time tracking app called Eon

If I knew, how this is called, I could investigate the matter further, but as I didn't know what to look for, this is impossible.

I appreciate any kind of hint.

Thanks a lot.

Upvotes: 6

Views: 1801

Answers (1)

Adam Leonard
Adam Leonard

Reputation: 489

The app in the screenshot looks like it's using a customized NSDrawer. Drawers slide out from a side of a window and can display any content.

Take a look at the documentation to see if it's what you want: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Drawers/Drawers.html#//apple_ref/doc/uid/10000001-BABFIBIA

Drawers are easy to set up. However, while you have full control over the content inside a drawer, you don't have much control over how the border looks without using private APIs (e.g., the ragged edges in the screenshot). If you want more control, you can use a borderless child window.

Here's a tutorial that makes a borderless, entirely custom window: http://cocoawithlove.com/2008/12/drawing-custom-window-on-mac-os-x.html

Then, you can "attach" your custom window to the parent window with -[NSWindow addChildWindow:ordered:]. That will allow the child window to follow the parent window as it moves. You will still need to respond to changes to the parent window size, and perhaps some other properties, on your own.

Upvotes: 9

Related Questions