• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: orderBack: only works when frontmost?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: orderBack: only works when frontmost?


  • Subject: Re: orderBack: only works when frontmost?
  • From: Adam Knight <email@hidden>
  • Date: Wed, 21 Feb 2007 14:11:34 -0600

This is the best solution I've come up with, and while the main windows still flash, they flash in the background. It's not ideal, though. I'd really rather find a way to stop activateIgnoringOtherApps from bringing the main windows forward, or find another way to bring only one of my panels to the foreground and receive keyboard input. Anyone have a better idea?

(The reason for the delayed orderBack is because activateIgnoring... is a delayed action itself, so I have to queue mine after it in the event queue.)

- (void) displayPanel
{
[NSApp activateIgnoringOtherApps:YES];

NSEnumerator *enu = [[NSApp orderedWindows] objectEnumerator];
NSWindow *aWindow;
while (aWindow = [enu nextObject]) {
if ([aWindow isVisible]) {
[aWindow orderOut:self];
[aWindow performSelector:@selector(orderBack:) withObject:self afterDelay:0.0];
}
}

[quickNotePanel setFloatingPanel:YES];
[quickNotePanel setHidesOnDeactivate:NO];
[quickNotePanel makeKeyAndOrderFront:self];
}




Adam Knight
codepoetry - http://www.codepoetry.net/products/


On Feb 20, 2007, at 6:09 PM, Adam Knight wrote:

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

_______________________________________________

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


References: 
 >orderBack: only works when frontmost? (From: Adam Knight <email@hidden>)

  • Prev by Date: Re: Error using categories: 'cannot find interface section for MyClass'
  • Next by Date: checkbox delegate
  • Previous by thread: orderBack: only works when frontmost?
  • Next by thread: Changing the Color of NSProgressIndicator with CGContextSetBlendMode
  • Index(es):
    • Date
    • Thread