Source Code Cross Referenced for KeyMap.java in  » Ajax » gwtext-2.01 » com » gwtext » client » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Ajax » gwtext 2.01 » com.gwtext.client.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * GWT-Ext Widget Library
003:         * Copyright(c) 2007-2008, GWT-Ext.
004:         * licensing@gwt-ext.com
005:         * 
006:         * http://www.gwt-ext.com/license
007:         */
008:        package com.gwtext.client.util;
009:
010:        import com.google.gwt.core.client.JavaScriptObject;
011:        import com.google.gwt.user.client.Element;
012:        import com.gwtext.client.core.JsObject;
013:
014:        /**
015:         * Handles mapping keys to actions for an element. One key map can be used for multiple actions.
016:         * If you bind a callback function to a KeyMap, anytime the KeyMap handles an expected key combination it will call the
017:         * function with this signature (if the match is a multi-key combination the callback will still be called only once):
018:         * (String key, EventObject e) A KeyMap can also handle a string representation of keys.
019:         * <p/>
020:         * <pre>
021:         *       // map one key by key code
022:         *       KeyMap map = new KeyMap("my-element", new KeyMapConfig() {
023:         *           {
024:         *               setKey(13);  // or EventObject.ENTER
025:         *               setKeyListener(new KeyListener() {
026:         *                   public void onKey(int key, EventObject e) {
027:         *                       //handle key
028:         *                   }
029:         *               });
030:         *           }
031:         *       });
032:         * <p/>
033:         *       // map multiple keys to one action by string
034:         *       KeyMap map = new KeyMap("my-element", new KeyMapConfig() {
035:         *           {
036:         *               setKey("a\r\n\t");
037:         *               setKeyListener(new KeyListener() {
038:         *                   public void onKey(int key, EventObject e) {
039:         *                       //handle key
040:         *                   }
041:         *               });
042:         *           }
043:         *       });
044:         * <p/>
045:         *       KeyMap map = new KeyMap("my-element", new KeyMapConfig() {
046:         *          {
047:         *               setKey(new int[]{10, 13});
048:         *               setKeyListener(new KeyListener() {
049:         *                   public void onKey(int key, EventObject e) {
050:         *                       // return was pressed
051:         *                   }
052:         *               });
053:         *           }
054:         *       });
055:         * <p/>
056:         *       KeyMap map = new KeyMap("my-element", new KeyMapConfig() {
057:         *           {
058:         *               setKey("abc");
059:         *               setKeyListener(new KeyListener() {
060:         *                   public void onKey(int key, EventObject e) {
061:         *                       // a, b or c was pressed
062:         *                   }
063:         *               });
064:         *           }
065:         *       });
066:         * <p/>
067:         *       KeyMap map = new KeyMap("my-element", new KeyMapConfig() {
068:         *           {
069:         *               setKey("\t");
070:         *               setCtrl(true);
071:         *               setShift(true);
072:         *               setKeyListener(new KeyListener() {
073:         *                   public void onKey(int key, EventObject e) {
074:         *                       // Ctrl + shift + tab was pressed
075:         *                   }
076:         *               });
077:         *           }
078:         *       });
079:         * <p/>
080:         *  </pre>
081:         */
082:        public class KeyMap extends JsObject {
083:
084:            public KeyMap(JavaScriptObject jsObj) {
085:                super (jsObj);
086:            }
087:
088:            /**
089:             * Create a new key map for the element.
090:             *
091:             * @param id     the element id
092:             * @param config keymap config
093:             */
094:            public KeyMap(String id, KeyMapConfig config) {
095:                this (id, config, null);
096:            }
097:
098:            /**
099:             * Create a new key map for the element.
100:             *
101:             * @param el     the element
102:             * @param config keymap config
103:             */
104:            public KeyMap(Element el, KeyMapConfig config) {
105:                this (el, config, null);
106:            }
107:
108:            /**
109:             * Create a new key map for the element.
110:             *
111:             * @param id        the element id
112:             * @param config    keymap config
113:             * @param eventName the event to bind to (defaults to "keydown")
114:             */
115:            public KeyMap(String id, KeyMapConfig config, String eventName) {
116:                jsObj = create(id, config.getJsObj(), eventName);
117:            }
118:
119:            /**
120:             * Create a new key map for the element.
121:             *
122:             * @param el        the element
123:             * @param config    keymap config
124:             * @param eventName the event to bind to (defaults to "keydown")
125:             */
126:            public KeyMap(Element el, KeyMapConfig config, String eventName) {
127:                jsObj = create(el, config.getJsObj(), eventName);
128:            }
129:
130:            private static native JavaScriptObject create(Element el,
131:                    JavaScriptObject config, String eventName) /*-{
132:                   return new  $wnd.Ext.KeyMap(el, config, eventName);
133:               }-*/;
134:
135:            private static native JavaScriptObject create(String id,
136:                    JavaScriptObject config, String eventName) /*-{
137:                   return new  $wnd.Ext.KeyMap(id, config, eventName);
138:               }-*/;
139:
140:            private static KeyMap instance(JavaScriptObject jsObj) {
141:                return new KeyMap(jsObj);
142:            }
143:
144:            /**
145:             * Add a new binding to this KeyMap.
146:             *
147:             * @param config new binding config
148:             */
149:            public native void addBinding(KeyMapConfig config) /*-{
150:                   var km = this.@com.gwtext.client.core.JsObject::getJsObj()();
151:                   var configJS = this.@com.gwtext.client.core.JsObject::getJsObj()();
152:                   km.addBinding(configJS);
153:               }-*/;
154:
155:            /**
156:             * Disable this KeyMap.
157:             */
158:            public native void disable() /*-{
159:                   var km = this.@com.gwtext.client.core.JsObject::getJsObj()();
160:                   km.disable();
161:               }-*/;
162:
163:            /**
164:             * Enable this KeyMap,
165:             */
166:            public native void enable() /*-{
167:                   var km = this.@com.gwtext.client.core.JsObject::getJsObj()();
168:                   km.enable();
169:               }-*/;
170:
171:            /**
172:             * Returns true if this KeyMap is enabled.
173:             *
174:             * @return true if enabled
175:             */
176:            public native boolean isEnabled() /*-{
177:                   var km = this.@com.gwtext.client.core.JsObject::getJsObj()();
178:                   return km.isEnabled();
179:               }-*/;
180:
181:            /**
182:             * True to stop the event from bubbling and prevent the default browser action if the key was handled by the KeyMap
183:             * (defaults to false).
184:             *
185:             * @param stopEvent true to stop event bubbling
186:             */
187:            public native void setStopEvent(boolean stopEvent) /*-{
188:                   var km = this.@com.gwtext.client.core.JsObject::getJsObj()();
189:                   km.stopEvent = stopEvent;
190:               }-*/;
191:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.