public class

AutoDirectionHandler

extends Object
implements KeyUpHandler HasDirectionEstimator
java.lang.Object
   ↳ com.google.gwt.i18n.client.AutoDirectionHandler

Class Overview

Utility class for handling auto-direction adjustment. This class is useful for automatically adjusting the direction of an object that takes text input, while the text is being entered.

Summary

Nested Classes
interface AutoDirectionHandler.Target The interface an object must implement in order to add an AutoDirectionHandler to it. 
Public Methods
static AutoDirectionHandler addTo(AutoDirectionHandler.Target target, DirectionEstimator directionEstimator)
Adds auto-direction adjustment to a given object: - Creates an AutoDirectionHandler.
static AutoDirectionHandler addTo(AutoDirectionHandler.Target target, boolean enabled)
Operates like addTo(Target, DirectionEstimator), but uses a default DirectionEstimator, WordCountDirectionEstimator if enabled, or else a null DirectionEstimator, which means disabling direction estimation.
static AutoDirectionHandler addTo(AutoDirectionHandler.Target target)
Operates like addTo(Target, DirectionEstimator), but always uses a default DirectionEstimator, WordCountDirectionEstimator.
DirectionEstimator getDirectionEstimator()
Returns the DirectionEstimator object.
void onKeyUp(KeyUpEvent event)
Automatically adjusts hasDirection's direction on KeyUpEvent events.
void refreshDirection()
Adjusts target's direction according to the estimated direction of the text it supplies.
void setDirectionEstimator(DirectionEstimator directionEstimator)
Sets the DirectionEstimator object.
void setDirectionEstimator(boolean enabled)
Toggles direction estimation on (using a default estimator) and off.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.gwt.event.dom.client.KeyUpHandler
From interface com.google.gwt.i18n.shared.HasDirectionEstimator

Public Methods

public static AutoDirectionHandler addTo (AutoDirectionHandler.Target target, DirectionEstimator directionEstimator)

Adds auto-direction adjustment to a given object: - Creates an AutoDirectionHandler. - Initializes it with the given DirectionEstimator. - Adds it as an event handler for the relevant events on the given object. - Returns the AutoDirectionHandler, so its setAutoDir() method can be called when the object's text changes by means other than the handled events.

Parameters
target Object whose direction should be automatically adjusted on relevant events.
directionEstimator A DirectionEstimator object used for direction estimation (use null to disable direction estimation).
Returns
  • AutoDirectionHandler An instance of AutoDirectionHandler for the given object.

public static AutoDirectionHandler addTo (AutoDirectionHandler.Target target, boolean enabled)

Operates like addTo(Target, DirectionEstimator), but uses a default DirectionEstimator, WordCountDirectionEstimator if enabled, or else a null DirectionEstimator, which means disabling direction estimation.

Parameters
target Object whose direction should be automatically adjusted on relevant events.
enabled Whether the handler is enabled upon creation.
Returns
  • AutoDirectionHandler An instance of AutoDirectionHandler for the given object.

public static AutoDirectionHandler addTo (AutoDirectionHandler.Target target)

Operates like addTo(Target, DirectionEstimator), but always uses a default DirectionEstimator, WordCountDirectionEstimator.

Parameters
target Object whose direction should be automatically adjusted on relevant events.
Returns
  • AutoDirectionHandler An instance of AutoDirectionHandler for the given object.

public DirectionEstimator getDirectionEstimator ()

Returns the DirectionEstimator object.

public void onKeyUp (KeyUpEvent event)

Automatically adjusts hasDirection's direction on KeyUpEvent events. Implementation of KeyUpHandler interface method.

Parameters
event the KeyUpEvent that was fired

public void refreshDirection ()

Adjusts target's direction according to the estimated direction of the text it supplies.

public void setDirectionEstimator (DirectionEstimator directionEstimator)

Sets the DirectionEstimator object.

Parameters
directionEstimator The {code DirectionEstimator} to be set. null means turning off direction estimation.

public void setDirectionEstimator (boolean enabled)

Toggles direction estimation on (using a default estimator) and off.

Parameters
enabled Whether to enable direction estimation. If true, sets the DirectionEstimator object to a default DirectionEstimator.