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 widget that implements this interface can receive keyboard focus.
020     */
021    public interface HasFocus extends SourcesFocusEvents, SourcesKeyboardEvents {
022    
023      /**
024       * Sets the widget's 'access key'. This key is used (in conjunction with a
025       * browser-specific modifier key) to automatically focus the widget.
026       * 
027       * @param key the widget's access key
028       */
029      public void setAccessKey(char key);
030    
031      /**
032       * Explicitly focus/unfocus this widget. Only one widget can have focus
033       * at a time, and the widget that does will receive all keyboard events.
034       * 
035       * @param focused whether this widget should take focus or release it
036       */
037      public void setFocus(boolean focused);
038    
039      /**
040       * Gets the widget's position in the tab index.
041       * 
042       * @return the widget's tab index
043       */
044      public int getTabIndex();
045    
046      /**
047       * Sets the widget's position in the tab index. If more than one widget
048       * has the same tab index, each such widget will receive focus in an
049       * arbitrary order.  Setting the tab index to <code>-1</code> will cause this
050       * widget to be removed from the tab order.
051       * 
052       * @param index the widget's tab index
053       */
054      public void setTabIndex(int index);
055    }