| java.lang.Object com.gwtext.client.core.JsObject com.gwtext.client.util.KeyMap
KeyMap | public class KeyMap extends JsObject (Code) | | Handles mapping keys to actions for an element. One key map can be used for multiple actions.
If you bind a callback function to a KeyMap, anytime the KeyMap handles an expected key combination it will call the
function with this signature (if the match is a multi-key combination the callback will still be called only once):
(String key, EventObject e) A KeyMap can also handle a string representation of keys.
// map one key by key code
KeyMap map = new KeyMap("my-element", new KeyMapConfig() {
{
setKey(13); // or EventObject.ENTER
setKeyListener(new KeyListener() {
public void onKey(int key, EventObject e) {
//handle key
}
});
}
});
// map multiple keys to one action by string
KeyMap map = new KeyMap("my-element", new KeyMapConfig() {
{
setKey("a\r\n\t");
setKeyListener(new KeyListener() {
public void onKey(int key, EventObject e) {
//handle key
}
});
}
});
KeyMap map = new KeyMap("my-element", new KeyMapConfig() {
{
setKey(new int[]{10, 13});
setKeyListener(new KeyListener() {
public void onKey(int key, EventObject e) {
// return was pressed
}
});
}
});
KeyMap map = new KeyMap("my-element", new KeyMapConfig() {
{
setKey("abc");
setKeyListener(new KeyListener() {
public void onKey(int key, EventObject e) {
// a, b or c was pressed
}
});
}
});
KeyMap map = new KeyMap("my-element", new KeyMapConfig() {
{
setKey("\t");
setCtrl(true);
setShift(true);
setKeyListener(new KeyListener() {
public void onKey(int key, EventObject e) {
// Ctrl + shift + tab was pressed
}
});
}
});
|
Method Summary | |
native public void | addBinding(KeyMapConfig config) Add a new binding to this KeyMap. | native public void | disable() Disable this KeyMap. | native public void | enable() | native public boolean | isEnabled() Returns true if this KeyMap is enabled. | native public void | setStopEvent(boolean stopEvent) True to stop the event from bubbling and prevent the default browser action if the key was handled by the KeyMap
(defaults to false). |
KeyMap | public KeyMap(JavaScriptObject jsObj)(Code) | | |
KeyMap | public KeyMap(String id, KeyMapConfig config)(Code) | | Create a new key map for the element.
Parameters: id - the element id Parameters: config - keymap config |
KeyMap | public KeyMap(Element el, KeyMapConfig config)(Code) | | Create a new key map for the element.
Parameters: el - the element Parameters: config - keymap config |
KeyMap | public KeyMap(String id, KeyMapConfig config, String eventName)(Code) | | Create a new key map for the element.
Parameters: id - the element id Parameters: config - keymap config Parameters: eventName - the event to bind to (defaults to "keydown") |
KeyMap | public KeyMap(Element el, KeyMapConfig config, String eventName)(Code) | | Create a new key map for the element.
Parameters: el - the element Parameters: config - keymap config Parameters: eventName - the event to bind to (defaults to "keydown") |
addBinding | native public void addBinding(KeyMapConfig config)(Code) | | Add a new binding to this KeyMap.
Parameters: config - new binding config |
disable | native public void disable()(Code) | | Disable this KeyMap.
|
enable | native public void enable()(Code) | | Enable this KeyMap,
|
isEnabled | native public boolean isEnabled()(Code) | | Returns true if this KeyMap is enabled.
true if enabled |
setStopEvent | native public void setStopEvent(boolean stopEvent)(Code) | | True to stop the event from bubbling and prevent the default browser action if the key was handled by the KeyMap
(defaults to false).
Parameters: stopEvent - true to stop event bubbling |
Fields inherited from com.gwtext.client.core.JsObject | protected JavaScriptObject jsObj(Code)(Java Doc)
|
|
|