0

i have an app and i try it on multi screen. I have two screens and i want to disable focus on the second screen when the both sreens are enterFullscreen, i want to force the focus on the main screen. I tried solutions i found here but doesn't change anything.

following code shows how i enterFullScreen for my mainWindow and my second Window

[self.window.contentView enterFullScreenMode:[[NSScreen screens] firstObject] withOptions:nil];
        [windowArray insertObject:self.window atIndex:0];

        NSRect screenRect;
        NSArray *screenArray = [NSScreen screens];
        for (NSInteger index = 1; index < [screenArray count]; index++)

        {

            NSScreen *screen = [screenArray objectAtIndex: index];

            screenRect = CGRectMake(0, 0, screen.frame.size.width , screen.frame.size.height);
            NSWindow *window = [[NSWindow alloc] initWithContentRect:screenRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO screen:screen];

            [window.contentView setWantsLayer:YES];
            window.contentView.layer.backgroundColor = [NSColor blackColor].CGColor;

            [window.contentView enterFullScreenMode:[[NSScreen screens] objectAtIndex:index] withOptions:nil];
            [windowArray addObject:window];

        }

When both screens are in fullScreen mode, when i click on the second window i have the focus on the second window (normal event) but i want to disable that and force to put the focus on my main Window. I tried to disable mouse event on the second screen but.. not working. If someone can help me ! thanks in advance

Community
  • 1
  • 1
miDark
  • 83
  • 9

1 Answers1

0

I don't know if it's the best answer for you, but you can iterate through all the subviews of the content view, and call setEnabled: on all of them. You can see a better and complete answer here: https://stackoverflow.com/a/16336624/2923506

for (NSView *object in [self.window.contentView subviews]) {

     // Check it out the object
         // set enable to NO [(id)object setEnabled:NO];

}
Community
  • 1
  • 1
J. Lopes
  • 1,336
  • 16
  • 27