Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Catching Command-N without any open windows?



I agree that in the context of the problem, a global menu bar is probably the best way to go.

However, another way would be to write a custom KeyEventDispatcher and add it to the KeyboardFocusManager.

eg:

KeyEventDispatcher ked = new MyKeyEventDispatcher();

KeyboardFocusManager.getCurrentKeyboardFocusManager ().addKeyEventDispatcher( ked );

this lets you install a handler to get "first crack" at any keyboard event before the normal event processing occurs.


Rob


On May 3, 2006, at 2:20 PM, Bruno Schaeffer wrote:

Hi,

I guess your application should have a (global) menu bar even when there are no open windows. Command-N is then just a short cut for the corresponding menu entry. You can simulate the global menu bar without having a window by creating an off-display window. The menu of this off-site window can then be used when no application/ document windows are open.

Cheers

--Bruno

On 03.05.2006, at 20:42, Bill Janssen wrote:

Hi. I've got a Swing document viewer app that may or may not have
open windows (documents). I'd like to bind Command-N to pop up a new
query window (to seach for new documents) and have it work even if
there are no open windows. Generating a ReOpenApplication event would
be fine. But I don't see how to bind key actions without a Window to
bind them to. I'm hoping I don't have to mess around trying to give
focus to an invisible window when there are no other open windows.


Bill



Rob Ross, Senior Software Engineer
E! Networks
email@hidden
---------------------------------------------------
"Beware of he who would deny you access to information, for in his heart he dreams himself your master." -- Commissioner Pravin Lal


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Catching Command-N without any open windows? (From: Bill Janssen <email@hidden>)
 >Re: Catching Command-N without any open windows? (From: Bruno Schaeffer <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.