Package com.google.gwt.i18n.client
Class AutoDirectionHandler
java.lang.Object
com.google.gwt.i18n.client.AutoDirectionHandler
- All Implemented Interfaces:
KeyUpHandler
,EventHandler
,HasDirectionEstimator
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
The interface an object must implement in order to add an AutoDirectionHandler to it. -
Method Summary
Modifier and TypeMethodDescriptionstatic AutoDirectionHandler
addTo
(AutoDirectionHandler.Target target) Operates likeaddTo(Target, DirectionEstimator)
, but always uses a default DirectionEstimator,WordCountDirectionEstimator
.static AutoDirectionHandler
addTo
(AutoDirectionHandler.Target target, boolean enabled) Operates likeaddTo(Target, DirectionEstimator)
, but uses a default DirectionEstimator,WordCountDirectionEstimator
ifenabled
, or else a null DirectionEstimator, which means disabling direction estimation.static AutoDirectionHandler
addTo
(AutoDirectionHandler.Target target, DirectionEstimator directionEstimator) Adds auto-direction adjustment to a given object: - Creates an AutoDirectionHandler.Returns the DirectionEstimator object.void
onKeyUp
(KeyUpEvent event) Automatically adjusts hasDirection's direction on KeyUpEvent events.void
Adjusts target's direction according to the estimated direction of the text it supplies.void
setDirectionEstimator
(boolean enabled) Toggles direction estimation on (using a default estimator) and off.void
setDirectionEstimator
(DirectionEstimator directionEstimator) Sets the DirectionEstimator object.
-
Method Details
-
addTo
Operates likeaddTo(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.
-
addTo
Operates likeaddTo(Target, DirectionEstimator)
, but uses a default DirectionEstimator,WordCountDirectionEstimator
ifenabled
, 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.
-
getDirectionEstimator
Returns the DirectionEstimator object.- Specified by:
getDirectionEstimator
in interfaceHasDirectionEstimator
-
onKeyUp
Automatically adjusts hasDirection's direction on KeyUpEvent events. Implementation of KeyUpHandler interface method.- Specified by:
onKeyUp
in interfaceKeyUpHandler
- Parameters:
event
- theKeyUpEvent
that was fired
-
refreshDirection
public void refreshDirection()Adjusts target's direction according to the estimated direction of the text it supplies. -
setDirectionEstimator
public void setDirectionEstimator(boolean enabled) Toggles direction estimation on (using a default estimator) and off.- Specified by:
setDirectionEstimator
in interfaceHasDirectionEstimator
- Parameters:
enabled
- Whether to enable direction estimation. Iftrue
, sets theDirectionEstimator
object to a defaultDirectionEstimator
.
-