| Author |
InputMap / ActionMap actions leave characters in TextArea
|
Chris Kimball
Greenhorn
Joined: Apr 23, 2012
Posts: 29
|
|
I've added a JPopupMenu to a JPanel with a TextArea in it. The popup menu is attached to the TextArea with the usual MouseListener.
To bring up the popup menu with a keystroke, I've gotten the InputMap and added a (key, action) pair to it. The key is an alt P, the action is a defined Action instance.
The software works fine in popping up the menu and closing the menu. Alas, if the focus is on the text area, alt p ALSO produces a "pi" symbol in the text area.
The Action class uses an ActionEvent that doesn't have a consume() method. What sort of action for the ActionMap should I be using so that I can consume the alt P?
Thanks,
Chris
Here's a snippet :
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4163
|
|
|
If you don't want the default action of the keystroke to affect the text area, remove that mapping from the appropriate input map of the text area.
|
luck, db
There are no new questions, but there may be new answers.
|
 |
 |
|
|
subject: InputMap / ActionMap actions leave characters in TextArea
|
|
|