Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread Display Modes
Old Feb 26, 2013, 04:08 AM   #1
macrumors 6502
Join Date: Mar 2007
Show Window without activating (keep application below it active)

I need to show a window (without title bar) above third party applications without my window taking focus.

I have tried using an NSPanel and setting enabling non-activating, but that didn't help.

I tried orderFront:self, but that didn't help either.

I always needed to add [NSApp activateIgnoringOtherApps:YES]; because the window wouldn't show otherwise.

I have here a sample project for just this functionality:

UIElement is set to true in the application's plist file, so there is no dock. You can activate the window by pressing ALT + SPACE at the same time. You will see that the app below it looses focus. Any thoughts on how to fix this? I've seen other apps do it so I know it's possible.

Edit: here's the code so far. Remember the window is a non-activating NSPanel. I still need that last NSApp activateIgnoringOtherApps line or otherwise it doesn't display. But of course that makes the window the active one.

 _windowController = [[MyWindowController alloc] initWithWindowNibName:@"MyWindowController"];

    [[_windowController window] setLevel:NSNormalWindowLevel+1];
    [[_windowController window] orderFrontRegardless];

    [_windowController showWindow:self];

   [NSApp activateIgnoringOtherApps:YES];
I've also subclassed NSPanel and added two methods:

- (BOOL)canBecomeKeyWindow
    return NO;

- (BOOL)canBecomeMainWindow
    return NO;
(I also tried canBecomeKeyWindow return YES and several other levels (for setLevel).

Any ideas?
wesleyh is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Screen copy active window Barney63 MacBook Pro 3 Mar 14, 2014 12:49 AM
Assigning a hot key to a non active window? MarkC426 OS X 0 May 11, 2013 04:35 PM
Apps Switch but Active Window doesn't MacKenzie999 OS X 10.8 Mountain Lion 6 Nov 13, 2012 08:22 AM
Opening a file but the window isn't active? k6578 Mac Applications and Mac App Store 5 Oct 8, 2012 01:36 AM
Active Window in Mac OSX saqibjaan Mac Programming 11 Sep 14, 2012 07:12 AM

Forum Jump

All times are GMT -5. The time now is 12:52 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2015, MacRumors.com, LLC