Multiple actions for a single key press
From: Will Friedman (williamf_at_alum.mit.edu)
Date: 03/30/04
- Next message: Karsten Wutzke: "GUI update and threads"
- Previous message: A. Bolmarcich: "Re: What's the swing equivalent for Canvas?"
- Next in thread: Will Friedman: "Re: Multiple actions for a single key press"
- Reply: Will Friedman: "Re: Multiple actions for a single key press"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Mar 2004 13:30:41 -0800
Hi all,
I'm writing an UI that uses F1-F10 for its actions and have set up key
bindings for each of them. One particular action requires that the
immediately following input (F1-F10) do a new action in addition to
its regularly assigned action, but I'm having a devil of a time
figuring out how to do this. The most logical way it seemed would be
to (temporarily) assign multiple actions to each of the key bindings,
but it appears that InputMap & ActionMap's put() method overrides the
old binding instead of adding an _extra_ binding, which is what I
would have hoped would happen.
I then thought to assign the new action to all the keys which would in
the end rebind the keys to their old bindings and then manually run
the action associated with pressed key, but I can't figure out a way
to find out what the pressed key was! I thought to use ActionEvent's
getActionCommand() method, but that returns null for some reason. I
also thought to add a KeyListener which would add the pressed key to a
private variable, but doing so consumes all keyboard input such that
the actions associated with the bindings never happen at all!
Any help or ideas would be greatly appreciated.
Thank you,
Will
- Next message: Karsten Wutzke: "GUI update and threads"
- Previous message: A. Bolmarcich: "Re: What's the swing equivalent for Canvas?"
- Next in thread: Will Friedman: "Re: Multiple actions for a single key press"
- Reply: Will Friedman: "Re: Multiple actions for a single key press"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]