views:

159

answers:

1

I'm writing an app that has a custom, transparent NSWindow created using a NSWindow subclass with the following:

- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag 
{
   self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:bufferingType defer:flag];

   if (self)
   {
     [self setOpaque:NO];
     [self setBackgroundColor:[NSColor clearColor]];
   }

   return self;
}

- (BOOL)canBecomeKeyWindow
{
  return YES;
}

- (BOOL)canBecomeMainWindow
{
  return YES;
}

I have everything working perfectly, including dragging and resizing, except the window doesn't work with Spaces. I cannot move the window to another space by either holding the window while switching spaces via keyboard shortcut, or by dragging to the bottom/top/left/right of the window. Is there anyway to have a custom window behave exactly like a normal window with regards to Spaces?

A: 

Did you override isMovable?
The Apple documentation says, that it changes Spaces behavior:

If a window returns NO, that means it can only be dragged between spaces in F8 mode, ...

Another method that might be related: NSWindow setCollectionBehavior

weichsel
Unfortunately, isMovable has no effect, and setCollectionBehavior only allows me to force the app to appear on all spaces. I did find that by using setMovableByWindowBackground, everything works with regards to Spaces, but that interferes with my custom dragging and resizing code, which I don't want. So setMovableByWindowBackground must be doing something that enables the window to be moved between spaces.
Zach Waugh