Search code examples
objective-cxcodensrect

NSRect on main screen without window


I was wondering if it is possible to create an NSRect with maybe an NSMakeRect to make a simple square that will display on the screen without a window or any view behind it, just made all in code.

This is what I have as an example

-(void)drawRect
{
   NSRect myNewRect
   myNewRect = NSMakeRect(100, 100, 50, 50);
}

Thats just a simple starting point but it will not show up on the screen by itself. what do i need to add?

Thanks


Solution

  • Every drawing operation on Mac OS X requires some window of sort. So no, you cannot draw a rect without a window. But you can create a transparent window without any borders to draw into.