This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Confused over InputMap?  RSS feed

 
Richard Gravenor
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone.

I have a problem understanding the InputMap of a JTextArea.
Basically, I have disabled the parent InputMap using: 'jTextArea1.getInputMap().setParent(null);' so that I could control the key events for the text area and encapsulate each key entry into a Command object to use in an Undo/Redo mechanism. This works fine, except for the Arrow Keys (and maybe others, too, I haven't checked) which no longer produce an event that I can make use of.

I have read other tutorials that are similar to this subject, but I really don't know what I'm doing and I can't figure it out from the J-docs.

If anyone can explain to me how this works, and perhaps let me know how to enable the arrow keys, I'll be very grateful.

Cheers!

Rich
 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Setting the parent input map to null removes all the default bindings.

Therefore if you want to use some of the default Actions provided by the editor toolkit you need to add your own bindings:



Check out the Key Bindings program for a list of all the Action names.

It may be easer to only disable certain bindings. An example of how to do this is also givin in the above link.

If you need more help you should create a SSCCE, that demonstrates the incorrect behaviour.
 
Richard Gravenor
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers Rob, I'll look into it a little bit more and see if I can make more sense of it.

Thanks for your help.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!