001    /*
002     * Copyright 2006 Mat Gessel <mat.gessel@gmail.com>
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 asquare.gwt.tk.client.ui.behavior;
017    
018    import com.google.gwt.user.client.Event;
019    import com.google.gwt.user.client.ui.Widget;
020    
021    /**
022     * An EventDelegate processes events from a widget.
023     * <p>
024     * Example: <br/> To override default focus behavior you need to preview and
025     * cancel tab events. The KeyboardListener interface does not receive the actual
026     * events. EventPreview is really intended for popups and dialogs and will not
027     * function if another popup/dialog is shown (think a non-modal dialog or popup
028     * without autoclose). A solution is to have widget can delegate events to a
029     * focus manager implementing EventDelegate.
030     * </p>
031     */
032    public interface EventDelegate
033    {
034            /**
035             * Get a bitmask representing events this delegate is interested in
036             * processing. 
037             *  
038             * @return a bitmask of the events to process
039             * @see Event
040             */
041            int getEventBits();
042    
043            /**
044             * Call this from your widget's onBrowserEvent() method 
045             * to to delegate events. 
046             * 
047             * <p>Example: <p> 
048             * <pre>
049             * public void onBrowserEvent(Event event)
050             * {
051             *   super.onBrowserEvent(event);
052             *   delegate.onBrowserEvent(this, event);
053             * }
054             * </pre>
055             * 
056             * @param widget the wiget that originated the event
057             * @param event the event
058             */
059            void onBrowserEvent(Widget widget, Event event);
060    }