java.lang.Object
   ↳ com.google.gwt.user.client.ui.UIObject
     ↳ com.google.gwt.user.client.ui.Widget
       ↳ com.google.gwt.user.client.ui.FocusWidget
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Abstract base class for most widgets that can receive keyboard focus.

Summary

[Expand]
Inherited Constants
From class com.google.gwt.user.client.ui.UIObject
Protected Constructors
FocusWidget()
Creates a new focus widget with no element.
FocusWidget(Element elem)
Creates a new focus widget that wraps the specified browser element.
Public Methods
HandlerRegistration addBlurHandler(BlurHandler handler)
Adds a BlurEvent handler.
HandlerRegistration addClickHandler(ClickHandler handler)
Adds a ClickEvent handler.
void addClickListener(ClickListener listener)
This method is deprecated. Use addClickHandler(ClickHandler) instead
HandlerRegistration addDoubleClickHandler(DoubleClickHandler handler)
Adds a DoubleClickEvent handler.
HandlerRegistration addFocusHandler(FocusHandler handler)
Adds a FocusEvent handler.
void addFocusListener(FocusListener listener)
This method is deprecated. Use addFocusHandler(FocusHandler) instead
HandlerRegistration addGestureChangeHandler(GestureChangeHandler handler)
Adds a GestureChangeEvent handler.
HandlerRegistration addGestureEndHandler(GestureEndHandler handler)
Adds a GestureEndEvent handler.
HandlerRegistration addGestureStartHandler(GestureStartHandler handler)
Adds a GestureStartEvent handler.
HandlerRegistration addKeyDownHandler(KeyDownHandler handler)
Adds a KeyDownEvent handler.
HandlerRegistration addKeyPressHandler(KeyPressHandler handler)
Adds a KeyPressEvent handler.
HandlerRegistration addKeyUpHandler(KeyUpHandler handler)
Adds a KeyUpEvent handler.
void addKeyboardListener(KeyboardListener listener)
HandlerRegistration addMouseDownHandler(MouseDownHandler handler)
Adds a MouseDownEvent handler.
void addMouseListener(MouseListener listener)
HandlerRegistration addMouseMoveHandler(MouseMoveHandler handler)
Adds a MouseMoveEvent handler.
HandlerRegistration addMouseOutHandler(MouseOutHandler handler)
Adds a MouseOutEvent handler.
HandlerRegistration addMouseOverHandler(MouseOverHandler handler)
Adds a MouseOverEvent handler.
HandlerRegistration addMouseUpHandler(MouseUpHandler handler)
Adds a MouseUpEvent handler.
HandlerRegistration addMouseWheelHandler(MouseWheelHandler handler)
Adds a MouseWheelEvent handler.
void addMouseWheelListener(MouseWheelListener listener)
This method is deprecated. Use addMouseWheelHandler(MouseWheelHandler) instead
HandlerRegistration addTouchCancelHandler(TouchCancelHandler handler)
Adds a TouchCancelEvent handler.
HandlerRegistration addTouchEndHandler(TouchEndHandler handler)
Adds a TouchEndEvent handler.
HandlerRegistration addTouchMoveHandler(TouchMoveHandler handler)
Adds a TouchMoveEvent handler.
HandlerRegistration addTouchStartHandler(TouchStartHandler handler)
Adds a TouchStartEvent handler.
int getTabIndex()
Gets the tab index.
boolean isEnabled()
Gets whether this widget is enabled.
void removeClickListener(ClickListener listener)
This method is deprecated. Use the removeHandler() method on the object returned by addClickHandler(ClickHandler) instead
void removeFocusListener(FocusListener listener)
This method is deprecated. Use the removeHandler() method on the object returned by addFocusHandler(FocusHandler) instead
void removeKeyboardListener(KeyboardListener listener)
This method is deprecated. Use the removeHandler() method on the object returned by an add*Handler method instead
void removeMouseListener(MouseListener listener)
This method is deprecated. Use the removeHandler() method on the object returned by an add*Handler method instead
void removeMouseWheelListener(MouseWheelListener listener)
This method is deprecated. Use the removeHandler() method on the object returned by addMouseWheelHandler(MouseWheelHandler) instead
void setAccessKey(char key)
Sets the widget's 'access key'.
void setEnabled(boolean enabled)
Sets whether this widget is enabled.
void setFocus(boolean focused)
Explicitly focus/unfocus this widget.
void setTabIndex(int index)
Sets the widget's position in the tab index.
Protected Methods
static FocusImpl getFocusImpl()
Gets the FocusImpl instance.
void onAttach()

This method is called when a widget is attached to the browser's document.

[Expand]
Inherited Methods
From class com.google.gwt.user.client.ui.Widget
From class com.google.gwt.user.client.ui.UIObject
From class java.lang.Object
From interface com.google.gwt.event.dom.client.HasBlurHandlers
From interface com.google.gwt.event.dom.client.HasClickHandlers
From interface com.google.gwt.event.dom.client.HasDoubleClickHandlers
From interface com.google.gwt.event.dom.client.HasFocusHandlers
From interface com.google.gwt.event.dom.client.HasGestureChangeHandlers
From interface com.google.gwt.event.dom.client.HasGestureEndHandlers
From interface com.google.gwt.event.dom.client.HasGestureStartHandlers
From interface com.google.gwt.event.dom.client.HasKeyDownHandlers
From interface com.google.gwt.event.dom.client.HasKeyPressHandlers
From interface com.google.gwt.event.dom.client.HasKeyUpHandlers
From interface com.google.gwt.event.dom.client.HasMouseDownHandlers
From interface com.google.gwt.event.dom.client.HasMouseMoveHandlers
From interface com.google.gwt.event.dom.client.HasMouseOutHandlers
From interface com.google.gwt.event.dom.client.HasMouseOverHandlers
From interface com.google.gwt.event.dom.client.HasMouseUpHandlers
From interface com.google.gwt.event.dom.client.HasMouseWheelHandlers
From interface com.google.gwt.event.dom.client.HasTouchCancelHandlers
From interface com.google.gwt.event.dom.client.HasTouchEndHandlers
From interface com.google.gwt.event.dom.client.HasTouchMoveHandlers
From interface com.google.gwt.event.dom.client.HasTouchStartHandlers
From interface com.google.gwt.event.logical.shared.HasAttachHandlers
From interface com.google.gwt.event.shared.HasHandlers
From interface com.google.gwt.user.client.EventListener
From interface com.google.gwt.user.client.ui.Focusable
From interface com.google.gwt.user.client.ui.HasEnabled
From interface com.google.gwt.user.client.ui.IsWidget
From interface com.google.gwt.user.client.ui.SourcesClickEvents
From interface com.google.gwt.user.client.ui.SourcesFocusEvents
From interface com.google.gwt.user.client.ui.SourcesKeyboardEvents
From interface com.google.gwt.user.client.ui.SourcesMouseEvents

Protected Constructors

protected FocusWidget ()

Creates a new focus widget with no element. setElement(Element) must be called before any other methods.

protected FocusWidget (Element elem)

Creates a new focus widget that wraps the specified browser element.

Parameters
elem the element to be wrapped

Public Methods

public HandlerRegistration addBlurHandler (BlurHandler handler)

Adds a BlurEvent handler.

Parameters
handler the blur handler
Returns

public HandlerRegistration addClickHandler (ClickHandler handler)

Adds a ClickEvent handler.

Parameters
handler the click handler
Returns

public void addClickListener (ClickListener listener)

This method is deprecated.
Use addClickHandler(ClickHandler) instead

Adds a listener interface to receive click events.

Parameters
listener the listener interface to add

public HandlerRegistration addDoubleClickHandler (DoubleClickHandler handler)

Adds a DoubleClickEvent handler.

Parameters
handler the double click handler
Returns

public HandlerRegistration addFocusHandler (FocusHandler handler)

Adds a FocusEvent handler.

Parameters
handler the focus handler
Returns

public void addFocusListener (FocusListener listener)

This method is deprecated.
Use addFocusHandler(FocusHandler) instead

Adds a listener interface to receive focus events.

Parameters
listener the listener interface to add

public HandlerRegistration addGestureChangeHandler (GestureChangeHandler handler)

Adds a GestureChangeEvent handler.

Parameters
handler the mouse down handler
Returns

public HandlerRegistration addGestureEndHandler (GestureEndHandler handler)

Adds a GestureEndEvent handler.

Parameters
handler the mouse down handler
Returns

public HandlerRegistration addGestureStartHandler (GestureStartHandler handler)

Adds a GestureStartEvent handler.

Parameters
handler the mouse down handler
Returns

public HandlerRegistration addKeyDownHandler (KeyDownHandler handler)

Adds a KeyDownEvent handler.

Parameters
handler the key down handler
Returns

public HandlerRegistration addKeyPressHandler (KeyPressHandler handler)

Adds a KeyPressEvent handler.

Parameters
handler the key press handler
Returns

public HandlerRegistration addKeyUpHandler (KeyUpHandler handler)

Adds a KeyUpEvent handler.

Parameters
handler the key up handler
Returns

public void addKeyboardListener (KeyboardListener listener)

This method is deprecated.
Use addKeyDownHandler(KeyDownHandler), addKeyUpHandler(KeyUpHandler) and addKeyPressHandler(KeyPressHandler) instead

Adds a listener interface to receive keyboard events.

Parameters
listener the listener interface to add

public HandlerRegistration addMouseDownHandler (MouseDownHandler handler)

Adds a MouseDownEvent handler.

Parameters
handler the mouse down handler
Returns

public void addMouseListener (MouseListener listener)

This method is deprecated.
Use addMouseOverHandler(MouseOverHandler) addMouseMoveHandler(MouseMoveHandler), addMouseDownHandler(MouseDownHandler), addMouseUpHandler(MouseUpHandler) and addMouseOutHandler(MouseOutHandler) instead

Adds a listener interface to receive mouse events.

Parameters
listener the listener interface to add

public HandlerRegistration addMouseMoveHandler (MouseMoveHandler handler)

Adds a MouseMoveEvent handler.

Parameters
handler the mouse move handler
Returns

public HandlerRegistration addMouseOutHandler (MouseOutHandler handler)

Adds a MouseOutEvent handler.

Parameters
handler the mouse out handler
Returns

public HandlerRegistration addMouseOverHandler (MouseOverHandler handler)

Adds a MouseOverEvent handler.

Parameters
handler the mouse over handler
Returns

public HandlerRegistration addMouseUpHandler (MouseUpHandler handler)

Adds a MouseUpEvent handler.

Parameters
handler the mouse up handler
Returns

public HandlerRegistration addMouseWheelHandler (MouseWheelHandler handler)

Adds a MouseWheelEvent handler.

Parameters
handler the mouse wheel handler
Returns

public void addMouseWheelListener (MouseWheelListener listener)

This method is deprecated.
Use addMouseWheelHandler(MouseWheelHandler) instead

public HandlerRegistration addTouchCancelHandler (TouchCancelHandler handler)

Adds a TouchCancelEvent handler.

Parameters
handler the mouse down handler
Returns

public HandlerRegistration addTouchEndHandler (TouchEndHandler handler)

Adds a TouchEndEvent handler.

Parameters
handler the mouse down handler
Returns

public HandlerRegistration addTouchMoveHandler (TouchMoveHandler handler)

Adds a TouchMoveEvent handler.

Parameters
handler the mouse down handler
Returns

public HandlerRegistration addTouchStartHandler (TouchStartHandler handler)

Adds a TouchStartEvent handler.

Parameters
handler the mouse down handler
Returns

public int getTabIndex ()

Gets the tab index.

Returns
  • the tab index

public boolean isEnabled ()

Gets whether this widget is enabled.

Returns
  • true if the widget is enabled

public void removeClickListener (ClickListener listener)

This method is deprecated.
Use the removeHandler() method on the object returned by addClickHandler(ClickHandler) instead

Removes a previously added listener interface.

Parameters
listener the listener interface to remove

public void removeFocusListener (FocusListener listener)

This method is deprecated.
Use the removeHandler() method on the object returned by addFocusHandler(FocusHandler) instead

Removes a previously added listener interface.

Parameters
listener the listener interface to remove

public void removeKeyboardListener (KeyboardListener listener)

This method is deprecated.
Use the removeHandler() method on the object returned by an add*Handler method instead

Removes a previously added listener interface.

Parameters
listener the listener interface to remove

public void removeMouseListener (MouseListener listener)

This method is deprecated.
Use the removeHandler() method on the object returned by an add*Handler method instead

Removes a previously added listener interface.

Parameters
listener the listener interface to remove

public void removeMouseWheelListener (MouseWheelListener listener)

This method is deprecated.
Use the removeHandler() method on the object returned by addMouseWheelHandler(MouseWheelHandler) instead

public void setAccessKey (char key)

Sets the widget's 'access key'. This key is used (in conjunction with a browser-specific modifier key) to automatically focus the widget.

Parameters
key the widget's access key

public void setEnabled (boolean enabled)

Sets whether this widget is enabled.

Parameters
enabled true to enable the widget, false to disable it

public void setFocus (boolean focused)

Explicitly focus/unfocus this widget. Only one widget can have focus at a time, and the widget that does will receive all keyboard events.

Parameters
focused whether this widget should take focus or release it

public void setTabIndex (int index)

Sets the widget's position in the tab index. If more than one widget has the same tab index, each such widget will receive focus in an arbitrary order. Setting the tab index to -1 will cause this widget to be removed from the tab order.

Parameters
index the widget's tab index

Protected Methods

protected static FocusImpl getFocusImpl ()

Gets the FocusImpl instance.

Returns
  • impl

protected void onAttach ()

This method is called when a widget is attached to the browser's document. To receive notification after a Widget has been added to the document, override the onLoad() method or use addAttachHandler(AttachEvent.Handler).

It is strongly recommended that you override onLoad() or doAttachChildren() instead of this method to avoid inconsistencies between logical and physical attachment states.

Subclasses that override this method must call super.onAttach() to ensure that the Widget has been attached to its underlying Element.