GWT Tk 0.2.3

asquare.gwt.tk.client.util
Class KeyMap

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap
          extended by asquare.gwt.tk.client.util.KeyMap
All Implemented Interfaces:
Serializable, Cloneable, Map

public class KeyMap
extends HashMap

A map that facilitates looking up which command is associated to a hot key. Supports (char, Command) pairs. Similar to the Swing ActionMap.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
KeyMap()
           
 
Method Summary
 boolean containsKey(char keyCode)
          Determines if the map contains a mapping for the specified hot key.
 Command get(char keyCode)
          Get the command to which the specified hot key is mapped.
 void put(char keyCode, Command command)
          Create a mapping between a hot key and a command.
 Command remove(char keyCode)
          Remove a mapping for the specified hot key.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

KeyMap

public KeyMap()
Method Detail

put

public void put(char keyCode,
                Command command)
Create a mapping between a hot key and a command. To ensure case consistency across keypress and keydown/keyup events you can convert hot key characters to upper-case before creating the mapping.

Parameters:
keyCode - a keyboard shortcut
command - a Command to associate with the hot key

containsKey

public boolean containsKey(char keyCode)
Determines if the map contains a mapping for the specified hot key.

Parameters:
keyCode - a keyboard shortcut
Returns:
true if a mapping exists for keyCode

get

public Command get(char keyCode)
Get the command to which the specified hot key is mapped.

Parameters:
keyCode - a keyboard shortcut
Returns:
a Command or null

remove

public Command remove(char keyCode)
Remove a mapping for the specified hot key. Returns the previously mapped command, if applicable.

Parameters:
keyCode - a keyboard shortcut
Returns:
a Command or null

GWT Tk 0.2.3

© 2007 Mat Gessel