|
GWT 2.0.3 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
com.google.gwt.user.client.ui.Composite
com.google.gwt.user.client.ui.SuggestBox
public class SuggestBox
A SuggestBox is a text box or text area which displays a
pre-configured set of selections that match the user's input.
Each SuggestBox is associated with a single SuggestOracle.
The SuggestOracle is used to provide a set of selections given a
specific query string.
By default, the SuggestBox uses a MultiWordSuggestOracle as
its oracle. Below we show how a MultiWordSuggestOracle can be
configured:
MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
oracle.add("Cat");
oracle.add("Dog");
oracle.add("Horse");
oracle.add("Canary");
SuggestBox box = new SuggestBox(oracle);
Using the example above, if the user types "C" into the text widget, the
oracle will configure the suggestions with the "Cat" and "Canary"
suggestions. Specifically, whenever the user types a key into the text
widget, the value is submitted to the MultiWordSuggestOracle.
Note that there is no method to retrieve the "currently selected suggestion"
in a SuggestBox, because there are points in time where the currently
selected suggestion is not defined. For example, if the user types in some
text that does not match any of the SuggestBox's suggestions, then the
SuggestBox will not have a currently selected suggestion. It is more useful
to know when a suggestion has been chosen from the SuggestBox's list of
suggestions. A SuggestBox fires SuggestionEvents
whenever a suggestion is chosen, and handlers for these events can be added
using the addValueChangeHandler(ValueChangeHandler) method.
SuggestOracle,
MultiWordSuggestOracle,
TextBoxBase| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject |
|---|
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled |
| Field Summary |
|---|
| Fields inherited from class com.google.gwt.user.client.ui.UIObject |
|---|
DEBUG_ID_PREFIX |
| Constructor Summary | |
|---|---|
SuggestBox()
Constructor for SuggestBox. |
|
SuggestBox(SuggestOracle oracle)
Constructor for SuggestBox. |
|
SuggestBox(SuggestOracle oracle,
TextBoxBase box)
Constructor for SuggestBox. |
|
| Method Summary | |
|---|---|
void |
addChangeListener(ChangeListener listener)
Deprecated. use getTextBox()().addChangeHandler instead |
void |
addClickListener(ClickListener listener)
Deprecated. use getTextBox()().addClickHandler instead |
void |
addEventHandler(SuggestionHandler handler)
Deprecated. use addSelectionHandler(com.google.gwt.event.logical.shared.SelectionHandler instead. |
void |
addFocusListener(FocusListener listener)
Deprecated. use getTextBox()().addFocusHandler/addBlurHandler() instead |
void |
addKeyboardListener(KeyboardListener listener)
Deprecated. Use addKeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler), addKeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler) and addKeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler) instead |
HandlerRegistration |
addKeyDownHandler(KeyDownHandler handler)
Adds a KeyDownEvent handler. |
HandlerRegistration |
addKeyPressHandler(KeyPressHandler handler)
Adds a KeyPressEvent handler. |
HandlerRegistration |
addKeyUpHandler(KeyUpHandler handler)
Adds a KeyUpEvent handler. |
HandlerRegistration |
addSelectionHandler(SelectionHandler<SuggestOracle.Suggestion> handler)
Adds a SelectionEvent handler. |
HandlerRegistration |
addValueChangeHandler(ValueChangeHandler<java.lang.String> handler)
Adds a ValueChangeEvent handler. |
int |
getLimit()
Gets the limit for the number of suggestions that should be displayed for this box. |
SuggestOracle |
getSuggestOracle()
Gets the suggest box's SuggestOracle. |
int |
getTabIndex()
Gets the widget's position in the tab index. |
java.lang.String |
getText()
Gets this object's text. |
TextBoxBase |
getTextBox()
Get the text box associated with this suggest box. |
java.lang.String |
getValue()
Gets this object's value. |
void |
hideSuggestionList()
Hide current suggestions. |
boolean |
isAnimationEnabled()
|
boolean |
isAutoSelectEnabled()
Returns whether or not the first suggestion will be automatically selected. |
boolean |
isSuggestionListShowing()
|
protected void |
onEnsureDebugId(java.lang.String baseID)
Affected Elements: -popup = The popup that appears with suggestions. -items-item# = The suggested item at the specified index. |
void |
removeChangeListener(ChangeListener listener)
Deprecated. Use the HandlerRegistration.removeHandler()
method on the object returned by getTextBox()().addChangeHandler instead |
void |
removeClickListener(ClickListener listener)
Deprecated. Use the HandlerRegistration.removeHandler()
method on the object returned by getTextBox()().addClickHandler instead |
void |
removeEventHandler(SuggestionHandler handler)
Deprecated. Use the HandlerRegistration.removeHandler()
method no the object returned by addSelectionHandler(com.google.gwt.event.logical.shared.SelectionHandler instead |
void |
removeFocusListener(FocusListener listener)
Deprecated. Use the HandlerRegistration.removeHandler()
method on the object returned by getTextBox()().addFocusListener instead |
void |
removeKeyboardListener(KeyboardListener listener)
Deprecated. Use the HandlerRegistration.removeHandler()
method on the object returned by getTextBox()().add*Handler instead |
void |
setAccessKey(char key)
Sets the widget's 'access key'. |
void |
setAnimationEnabled(boolean enable)
Enable or disable animations. |
void |
setAutoSelectEnabled(boolean selectsFirstItem)
Turns on or off the behavior that automatically selects the first suggested item. |
void |
setFocus(boolean focused)
Explicitly focus/unfocus this widget. |
void |
setLimit(int limit)
Sets the limit to the number of suggestions the oracle should provide. |
void |
setPopupStyleName(java.lang.String style)
Sets the style name of the suggestion popup. |
void |
setTabIndex(int index)
Sets the widget's position in the tab index. |
void |
setText(java.lang.String text)
Sets this object's text. |
void |
setValue(java.lang.String newValue)
Sets this object's value without firing any events. |
void |
setValue(java.lang.String value,
boolean fireEvents)
Sets this object's value. |
void |
showSuggestionList()
Show the current list of suggestions. |
static SuggestBox |
wrap(SuggestOracle oracle,
Element element)
Creates a SuggestBox widget that wraps an existing <input
type='text'> element. |
| Methods inherited from class com.google.gwt.user.client.ui.Composite |
|---|
getWidget, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, setWidget |
| Methods inherited from class com.google.gwt.user.client.ui.Widget |
|---|
addDomHandler, addHandler, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents |
| Methods inherited from class com.google.gwt.user.client.ui.UIObject |
|---|
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, toString, unsinkEvents |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.google.gwt.event.shared.HasHandlers |
|---|
fireEvent |
| Constructor Detail |
|---|
public SuggestBox()
SuggestBox. Creates a
MultiWordSuggestOracle and TextBox to use with this
SuggestBox.
public SuggestBox(SuggestOracle oracle)
SuggestBox. Creates a TextBox to use with
this SuggestBox.
oracle - the oracle for this SuggestBox
public SuggestBox(SuggestOracle oracle,
TextBoxBase box)
SuggestBox. The text box will be removed from it's
current location and wrapped by the SuggestBox.
oracle - supplies suggestions based upon the current contents of the
text widgetbox - the text widget| Method Detail |
|---|
public static SuggestBox wrap(SuggestOracle oracle,
Element element)
SuggestBox widget that wraps an existing <input
type='text'> element.
This element must already be attached to the document. If the element is
removed from the document, you must call
RootPanel.detachNow(Widget).
oracle - the suggest box oracle to useelement - the element to be wrapped@Deprecated public void addChangeListener(ChangeListener listener)
getTextBox()().addChangeHandler instead
addChangeListener in interface SourcesChangeEventslistener - the listener interface to add@Deprecated public void addClickListener(ClickListener listener)
getTextBox()().addClickHandler instead
addClickListener in interface SourcesClickEventslistener - the listener interface to add@Deprecated public void addEventHandler(SuggestionHandler handler)
addSelectionHandler(com.google.gwt.event.logical.shared.SelectionHandler) instead.
addEventHandler in interface FiresSuggestionEventshandler - the handler to add@Deprecated public void addFocusListener(FocusListener listener)
getTextBox()().addFocusHandler/addBlurHandler() instead
addFocusListener in interface SourcesFocusEventslistener - the listener interface to add@Deprecated public void addKeyboardListener(KeyboardListener listener)
addKeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler), addKeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler) and addKeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler) instead
SourcesKeyboardEvents
addKeyboardListener in interface SourcesKeyboardEventslistener - the listener interface to addpublic HandlerRegistration addKeyDownHandler(KeyDownHandler handler)
HasKeyDownHandlersKeyDownEvent handler.
addKeyDownHandler in interface HasKeyDownHandlershandler - the key down handler
HandlerRegistration used to remove this handlerpublic HandlerRegistration addKeyPressHandler(KeyPressHandler handler)
HasKeyPressHandlersKeyPressEvent handler.
addKeyPressHandler in interface HasKeyPressHandlershandler - the key press handler
HandlerRegistration used to remove this handlerpublic HandlerRegistration addKeyUpHandler(KeyUpHandler handler)
HasKeyUpHandlersKeyUpEvent handler.
addKeyUpHandler in interface HasKeyUpHandlershandler - the key up handler
HandlerRegistration used to remove this handlerpublic HandlerRegistration addSelectionHandler(SelectionHandler<SuggestOracle.Suggestion> handler)
HasSelectionHandlersSelectionEvent handler.
addSelectionHandler in interface HasSelectionHandlers<SuggestOracle.Suggestion>handler - the handler
public HandlerRegistration addValueChangeHandler(ValueChangeHandler<java.lang.String> handler)
HasValueChangeHandlersValueChangeEvent handler.
addValueChangeHandler in interface HasValueChangeHandlers<java.lang.String>handler - the handler
public int getLimit()
SuggestOracle to enforce this
limit.
public SuggestOracle getSuggestOracle()
SuggestOracle.
SuggestOraclepublic int getTabIndex()
Focusable
getTabIndex in interface Focusablepublic java.lang.String getText()
HasText
getText in interface HasTextpublic TextBoxBase getTextBox()
public java.lang.String getValue()
HasValue
getValue in interface HasValue<java.lang.String>public void hideSuggestionList()
public boolean isAnimationEnabled()
isAnimationEnabled in interface HasAnimationpublic boolean isAutoSelectEnabled()
public boolean isSuggestionListShowing()
@Deprecated public void removeChangeListener(ChangeListener listener)
HandlerRegistration.removeHandler()
method on the object returned by getTextBox()().addChangeHandler instead
SourcesChangeEvents
removeChangeListener in interface SourcesChangeEventslistener - the listener interface to remove@Deprecated public void removeClickListener(ClickListener listener)
HandlerRegistration.removeHandler()
method on the object returned by getTextBox()().addClickHandler instead
SourcesClickEvents
removeClickListener in interface SourcesClickEventslistener - the listener interface to remove@Deprecated public void removeEventHandler(SuggestionHandler handler)
HandlerRegistration.removeHandler()
method no the object returned by addSelectionHandler(com.google.gwt.event.logical.shared.SelectionHandler) instead
FiresSuggestionEvents
removeEventHandler in interface FiresSuggestionEventshandler - the handler to remove@Deprecated public void removeFocusListener(FocusListener listener)
HandlerRegistration.removeHandler()
method on the object returned by getTextBox()().addFocusListener instead
SourcesFocusEvents
removeFocusListener in interface SourcesFocusEventslistener - the listener interface to remove@Deprecated public void removeKeyboardListener(KeyboardListener listener)
HandlerRegistration.removeHandler()
method on the object returned by getTextBox()().add*Handler instead
SourcesKeyboardEvents
removeKeyboardListener in interface SourcesKeyboardEventslistener - the listener interface to removepublic void setAccessKey(char key)
Focusable
setAccessKey in interface Focusablekey - the widget's access keypublic void setAnimationEnabled(boolean enable)
HasAnimation
setAnimationEnabled in interface HasAnimationenable - true to enable, false to disablepublic void setAutoSelectEnabled(boolean selectsFirstItem)
selectsFirstItem - Whether or not to automatically select the first
suggestionpublic void setFocus(boolean focused)
Focusable
setFocus in interface Focusablefocused - whether this widget should take focus or release itpublic void setLimit(int limit)
limit - the limit to the number of suggestions providedpublic void setPopupStyleName(java.lang.String style)
style - the new primary style nameUIObject.setStyleName(String)public void setTabIndex(int index)
Focusable-1 will cause this widget to
be removed from the tab order.
setTabIndex in interface Focusableindex - the widget's tab indexpublic void setText(java.lang.String text)
HasText
setText in interface HasTexttext - the object's new textpublic void setValue(java.lang.String newValue)
HasValueIt is acceptable to fail assertions or throw (documented) unchecked exceptions in response to bad values.
By convention, GWT widgets that can be cleared accept null for
value, but it is acceptable for widgets that cannot
be cleared to throw an exception for null values.
setValue in interface HasValue<java.lang.String>newValue - the object's new value
public void setValue(java.lang.String value,
boolean fireEvents)
HasValueValueChangeEvent when
fireEvents is true and the new value does not equal the existing value.
It is acceptable to fail assertions or throw (documented) unchecked exceptions in response to bad values.
setValue in interface HasValue<java.lang.String>value - the object's new valuefireEvents - fire events if true and value is newpublic void showSuggestionList()
protected void onEnsureDebugId(java.lang.String baseID)
onEnsureDebugId in class UIObjectbaseID - the base ID used by the main elementUIObject.onEnsureDebugId(String)
|
GWT 2.0.3 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||