Subversion Repository Public Repository

litesoft

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*
 * Copyright 2008 Google Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package com.google.gwt.gen2.event.dom.client;

import com.google.gwt.user.client.*;
import com.google.gwt.user.client.ui.*;

/**
 * Key up and key down are both events based upon a given key code.
 *
 * @deprecated use the com.google.gwt.event.dom.client classes instead
 */
@Deprecated
public abstract class KeyCodeEvent extends KeyEvent {

    /**
     * Alt key code.
     */
    public static final int KEY_ALT = 18;

    /**
     * Backspace key code.
     */
    public static final int KEY_BACKSPACE = 8;

    /**
     * Control key code.
     */
    public static final int KEY_CTRL = 17;

    /**
     * Delete key code.
     */
    public static final int KEY_DELETE = 46;

    /**
     * Down arrow code.
     */
    public static final int KEY_DOWN = 40;

    /**
     * End key code.
     */
    public static final int KEY_END = 35;
    /**
     * Enter key code.
     */
    public static final int KEY_ENTER = 13;
    /**
     * Escape key code.
     */
    public static final int KEY_ESCAPE = 27;
    /**
     * Home key code.
     */
    public static final int KEY_HOME = 36;
    /**
     * Left key code.
     */
    public static final int KEY_LEFT = 37;
    /**
     * Page down key code.
     */
    public static final int KEY_PAGEDOWN = 34;
    /**
     * Page up key code.
     */
    public static final int KEY_PAGEUP = 33;
    /**
     * Right arrow key code.
     */
    public static final int KEY_RIGHT = 39;

    /**
     * Shift key code.
     */
    public static final int KEY_SHIFT = 16;
    /**
     * Tab key code.
     */
    public static final int KEY_TAB = 9;

    /**
     * Up Arrow key code.
     */
    public static final int KEY_UP = 38;

    /**
     * Constructor.
     *
     * @param nativeEvent the wrapped native event
     */
    protected KeyCodeEvent( Event nativeEvent ) {
        super( nativeEvent );
    }

    /**
     * Gets the current key code.
     *
     * @return the key code
     */
    public int getKeyCode() {
        return getNativeEvent().getKeyCode();
    }

    /**
     * Is the key code alpha-numeric (i.e. A-z or 0-9)?
     *
     * @return is the key code alpha numeric.
     */
    public boolean isAlphaNumeric() {
        int keycode = getKeyCode();
        return (48 <= keycode && keycode <= 57) || (65 <= keycode && keycode <= 90);
    }

    /**
     * Does the key code represent an arrow key?
     *
     * @param code the key code
     *
     * @return if it is an arrow key code
     */
    public boolean isArrowKeyCode( int code ) {
        switch ( code ) {
            case KeyboardListener.KEY_DOWN:
            case KeyboardListener.KEY_RIGHT:
            case KeyboardListener.KEY_UP:
            case KeyboardListener.KEY_LEFT:
                return true;
            default:
                return false;
        }
    }

    /**
     * Is this a key down?
     *
     * @return whether this is a down arrow key event
     */
    public boolean isDownKeyCode() {
        return getKeyCode() == KEY_DOWN;
    }

    /**
     * Is this a key left?
     *
     * @return whether this is a left arrow key event
     */
    public boolean isLeftKeyCode() {
        return getKeyCode() == KEY_LEFT;
    }

    /**
     * Is this a key right?
     *
     * @return whether this is a right arrow key event
     */
    public boolean isRightKeyCode() {
        return getKeyCode() == KEY_RIGHT;
    }
}

Commits for litesoft/trunk/Java/GWT/Client/src/com/google/gwt/gen2/event/dom/client/KeyCodeEvent.java

Diff revisions: vs.
Revision Author Commited Message
950 Diff Diff GeorgeS picture GeorgeS Thu 19 Jun, 2014 17:57:04 +0000

New Lines

948 Diff Diff GeorgeS picture GeorgeS Sat 07 Jun, 2014 23:42:39 +0000

Jusefuls Formatter Updated to New Code Format

475 Diff Diff GeorgeS picture GeorgeS Sat 03 Sep, 2011 13:54:51 +0000
282 GeorgeS picture GeorgeS Fri 17 Jun, 2011 13:54:39 +0000