01: /*
02: * GWT-Ext Widget Library
03: * Copyright(c) 2007-2008, GWT-Ext.
04: * licensing@gwt-ext.com
05: *
06: * http://www.gwt-ext.com/license
07: */
08: package com.gwtext.client.util;
09:
10: import com.google.gwt.core.client.JavaScriptObject;
11: import com.google.gwt.user.client.Element;
12: import com.gwtext.client.core.JsObject;
13:
14: /**
15: * Provides a convenient wrapper for normalized keyboard navigation. KeyNav allows you to bind navigation keys to function
16: * calls that will get called when the keys are pressed, providing an easy way to implement custom navigation schemes for any UI component.
17: * <p/>
18: * The following are all of the possible keys that can be implemented: enter, left, right, up, down, tab, esc, pageUp, pageDown, del, home, end.
19: *
20: * @see com.gwtext.client.util.KeyNavConfig
21: */
22: public class KeyNav extends JsObject {
23:
24: public KeyNav(JavaScriptObject jsObj) {
25: super (jsObj);
26: }
27:
28: /**
29: * Creates a new KeyNav isntance.
30: *
31: * @param id the element ID
32: * @param config the keynav configuration
33: */
34: public KeyNav(String id, KeyNavConfig config) {
35: jsObj = create(id, config.getJsObj());
36: }
37:
38: /**
39: * Creates a new KeyNav isntance.
40: *
41: * @param el the element
42: * @param config the keynav configuration
43: */
44: public KeyNav(Element el, KeyNavConfig config) {
45: jsObj = create(el, config.getJsObj());
46: }
47:
48: private static native JavaScriptObject create(Element el,
49: JavaScriptObject config) /*-{
50: return new $wnd.Ext.KeyNav(el, config);
51: }-*/;
52:
53: private static native JavaScriptObject create(String id,
54: JavaScriptObject config) /*-{
55: return new $wnd.Ext.KeyNav(id, config);
56: }-*/;
57:
58: /**
59: * Disable the KeyNav.
60: */
61: public native void disable() /*-{
62: var kn = this.@com.gwtext.client.core.JsObject::getJsObj()();
63: kn.disable();
64: }-*/;
65:
66: /**
67: * Enable the KeyNav.
68: */
69: public native void enable() /*-{
70: var kn = this.@com.gwtext.client.core.JsObject::getJsObj()();
71: kn.enable();
72: }-*/;
73: }
|