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 widget that implements this interface can receive keyboard focus. 20 */ 21 public interface HasFocus extends SourcesFocusEvents, SourcesKeyboardEvents { 22 23 /** 24 * Gets the widget's position in the tab index. 25 * 26 * @return the widget's tab index 27 */ 28 public int getTabIndex(); 29 30 /** 31 * Sets the widget's 'access key'. This key is used (in conjunction with a 32 * browser-specific modifier key) to automatically focus the widget. 33 * 34 * @param key the widget's access key 35 */ 36 public void setAccessKey(char key); 37 38 /** 39 * Explicitly focus/unfocus this widget. Only one widget can have focus at a 40 * time, and the widget that does will receive all keyboard events. 41 * 42 * @param focused whether this widget should take focus or release it 43 */ 44 public void setFocus(boolean focused); 45 46 /** 47 * Sets the widget's position in the tab index. If more than one widget has 48 * the same tab index, each such widget will receive focus in an arbitrary 49 * order. Setting the tab index to <code>-1</code> will cause this widget to 50 * be removed from the tab order. 51 * 52 * @param index the widget's tab index 53 */ 54 public void setTabIndex(int index); 55 } 56