1 /* 2 * Copyright 2006 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations under 14 * the License. 15 */ 16 package com.google.gwt.user.client.ui; 17 18 /** 19 * A class that implements this interface receives a preview of keyboard events 20 * before they are passed to the focused widget. 21 * 22 * @see com.google.gwt.user.client.ui.KeyboardListener 23 */ 24 public interface HasKeyPreview { 25 26 /** 27 * Called when a key-down event is received. 28 * 29 * @param key the physical key that was depressed. Constants for this value 30 * are defined in this interface with the KEYCODE prefix. 31 * @param modifiers the modifier keys pressed at when the event occurred. This 32 * value is a combination of the bits defined by 33 * {@link KeyboardListener#MODIFIER_SHIFT}, 34 * {@link KeyboardListener#MODIFIER_CTRL}, and 35 * {@link KeyboardListener#MODIFIER_ALT}. 36 */ 37 boolean onKeyDownPreview(char key, int modifiers); 38 39 /** 40 * Called when a key-press event is received. 41 * 42 * @param key the Unicode character that was generated by the keyboard action. 43 * @param modifiers the modifier keys pressed at when the event occurred. This 44 * value is a combination of the bits defined by 45 * {@link KeyboardListener#MODIFIER_SHIFT}, 46 * {@link KeyboardListener#MODIFIER_CTRL}, and 47 * {@link KeyboardListener#MODIFIER_ALT}. 48 */ 49 boolean onKeyPressPreview(char key, int modifiers); 50 51 /** 52 * Called when a key-up event is received. 53 * 54 * @param key the physical key that was released. Constants for this value are 55 * defined in this interface with the KEYCODE prefix. 56 * @param modifiers the modifier keys pressed at when the event occurred. This 57 * value is a combination of the bits defined by 58 * {@link KeyboardListener#MODIFIER_SHIFT}, 59 * {@link KeyboardListener#MODIFIER_CTRL}, and 60 * {@link KeyboardListener#MODIFIER_ALT}. 61 */ 62 boolean onKeyUpPreview(char key, int modifiers); 63 } 64