001    /*
002     * Copyright 2006 Google Inc.
003     * 
004     * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005     * use this file except in compliance with the License. You may obtain a copy of
006     * the License at
007     * 
008     * http://www.apache.org/licenses/LICENSE-2.0
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012     * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013     * License for the specific language governing permissions and limitations under
014     * the License.
015     */
016    package com.google.gwt.user.client.ui;
017    
018    /**
019     * A class that implements this interface receives a preview of keyboard events
020     * before they are passed to the focused widget.
021     * 
022     * @see com.google.gwt.user.client.ui.KeyboardListener
023     */
024    public interface HasKeyPreview {
025    
026      /**
027       * Called when a key-down event is received.
028       * 
029       * @param key the physical key that was depressed. Constants for this value
030       *          are defined in this interface with the KEYCODE prefix.
031       * @param modifiers the modifier keys pressed at when the event occurred. This
032       *          value is a combination of the bits defined by
033       *          {@link KeyboardListener#MODIFIER_SHIFT},
034       *          {@link KeyboardListener#MODIFIER_CTRL}, and
035       *          {@link KeyboardListener#MODIFIER_ALT}.
036       */
037      boolean onKeyDownPreview(char key, int modifiers);
038    
039      /**
040       * Called when a key-press event is received.
041       * 
042       * @param sender the widget that was focused when the event occurred.
043       * @param key the Unicode character that was generated by the keyboard action.
044       * @param modifiers the modifier keys pressed at when the event occurred. This
045       *          value is a combination of the bits defined by
046       *          {@link KeyboardListener#MODIFIER_SHIFT},
047       *          {@link KeyboardListener#MODIFIER_CTRL}, and
048       *          {@link KeyboardListener#MODIFIER_ALT}.
049       */
050      boolean onKeyPressPreview(char key, int modifiers);
051    
052      /**
053       * Called when a key-up event is received.
054       * 
055       * @param key the physical key that was released. Constants for this value are
056       *          defined in this interface with the KEYCODE prefix.
057       * @param modifiers the modifier keys pressed at when the event occurred. This
058       *          value is a combination of the bits defined by
059       *          {@link KeyboardListener#MODIFIER_SHIFT},
060       *          {@link KeyboardListener#MODIFIER_CTRL}, and
061       *          {@link KeyboardListener#MODIFIER_ALT}.
062       */
063      boolean onKeyUpPreview(char key, int modifiers);
064    }