4
votes

I want to draw on the screen with a transparent background, so that everything (e.g. open applications are still visible).

In windowDidLoad of my custom NSWindowController i have the follwing:

[self.window setOpaque: NO];
[self.window setHasShadow:NO];
[self.window setBackgroundColor:[NSColor clearColor]];
[self.window setStyleMask:NSBorderlessWindowMask]; 

My custom NSWindow overrides canBecomeKeyWindow

- (BOOL)canBecomeKeyWindow {
   return YES;
}

My View overrides drawRect

- (void)drawRect:(NSRect)rect {
  [[NSColor clearColor]set];
  NSRectFill(rect);
  ...
}

Problem: Trying to draw by using mouse events inside of my custom view results in the view/application beneath my Window to receive these events.

It justs works when i do not set the NSWindow styleMask to NSBorderlessWindowMask or by setting the background color of the custom view to semitransparent.

[[NSColor colorWithCalibratedRed:0 green:0 blue:0 alpha:0.05] set]

How can i draw on screen with full transparency and NSBorderlessWindowMask?

1
Adding [self.window setIgnoresMouseEvents:NO]; to windowDidLoad of my custom NSWindowController solved itmc_plectrum

1 Answers

0
votes

Adding

[self.window setIgnoresMouseEvents:NO];

to windowDidLoad of my custom NSWindowController solved it