|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.gwtext.client.core.JsObject
com.gwtext.client.util.KeyMap
public class KeyMap
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
}
});
}
});
| Field Summary |
|---|
| Fields inherited from class com.gwtext.client.core.JsObject |
|---|
jsObj |
| Constructor Summary | |
|---|---|
KeyMap(com.google.gwt.user.client.Element el,
KeyMapConfig config)
Create a new key map for the element. |
|
KeyMap(com.google.gwt.user.client.Element el,
KeyMapConfig config,
java.lang.String eventName)
Create a new key map for the element. |
|
KeyMap(com.google.gwt.core.client.JavaScriptObject jsObj)
|
|
KeyMap(java.lang.String id,
KeyMapConfig config)
Create a new key map for the element. |
|
KeyMap(java.lang.String id,
KeyMapConfig config,
java.lang.String eventName)
Create a new key map for the element. |
|
| Method Summary | |
|---|---|
void |
addBinding(KeyMapConfig config)
Add a new binding to this KeyMap. |
void |
disable()
Disable this KeyMap. |
void |
enable()
Enable this KeyMap, |
boolean |
isEnabled()
Returns true if this KeyMap is enabled. |
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). |
| Methods inherited from class com.gwtext.client.core.JsObject |
|---|
getJsObj, getProperties, isCreated, setJsObj |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public KeyMap(com.google.gwt.core.client.JavaScriptObject jsObj)
public KeyMap(java.lang.String id,
KeyMapConfig config)
id - the element idconfig - keymap config
public KeyMap(com.google.gwt.user.client.Element el,
KeyMapConfig config)
el - the elementconfig - keymap config
public KeyMap(java.lang.String id,
KeyMapConfig config,
java.lang.String eventName)
id - the element idconfig - keymap configeventName - the event to bind to (defaults to "keydown")
public KeyMap(com.google.gwt.user.client.Element el,
KeyMapConfig config,
java.lang.String eventName)
el - the elementconfig - keymap configeventName - the event to bind to (defaults to "keydown")| Method Detail |
|---|
public void addBinding(KeyMapConfig config)
config - new binding configpublic void disable()
public void enable()
public boolean isEnabled()
public void setStopEvent(boolean stopEvent)
stopEvent - true to stop event bubbling
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||