Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 26, 2013, 04:08 AM   #1
wesleyh
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:
http://users.telenet.be/prullen/TopW2.zip

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.

Code:
 _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:

Code:
- (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

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 12:19 AM.

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

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