orderBack: only works when frontmost?
orderBack: only works when frontmost?
- Subject: orderBack: only works when frontmost?
- From: Adam Knight <email@hidden>
- Date: Tue, 20 Feb 2007 18:09:55 -0600
I have a hot key whose sole purpose is to bring up a note-taking
window for the user. It is the user's desire for this window (and
this window alone) to appear and become key, ready for input. Now
that HIG concerns are out of the way...
What I have now only works the way I want when my app is frontmost.
The only way I can think to accomplish the above is to bring the
whole app forward, move all document windows to the back of the
window ordering, and make the QN panel key. Thus, I have:
- (void) displayPanel
{
[NSApp activateIgnoringOtherApps:YES];
// Use orderedWindows so that in the process of pushing windows back
// they retain their original order.
NSEnumerator *enu = [[NSApp orderedWindows] objectEnumerator];
NSWindow *aWindow;
while (aWindow = [enu nextObject]) {
if ([aWindow isVisible]) [aWindow orderBack:self];
}
[quickNotePanel setFloatingPanel:YES];
[quickNotePanel setHidesOnDeactivate:NO];
[quickNotePanel makeKeyAndOrderFront:self];
}
However, when something else is active orderBack: doesn't appear to
do anything. When my app is frontmost, then this works perfectly.
I've verified that isVisible is returning the proper values and that
orderBack: is being called properly, so I'm at a loss.
I even tried to simplify the above, knowing it would show hidden
windows, and did this with the same results:
[[NSApp orderedWindows] makeObjectsPerformSelector:@selector
(orderBack:) withObject:self];
The ONLY way I've gotten around this is to flush events after calling
activateIgnoringOtherApps: by doing:
NSEvent* event;
while (event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:
[NSDate dateWithTimeIntervalSinceNow:0.05]
inMode:NSDefaultRunLoopMode dequeue:YES])
[NSApp sendEvent:event];
It's not only hackish, but I get a flash of the main window if I use
that method. I'd rather not get anything but the panel.
Somehow alter NSApp's arrangeInFront? Help?
Adam Knight
If you're not going to stop and appreciate the scenery, you're not
going to
enjoy Myst. The same thing applies on the Mac as well. -- Rand Miller
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden