|
||||||||||
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
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
.
SuggestOracle, MultiWordSuggestOracle, TextBoxBase
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)
Adds a listener interface to receive change events. |
void |
addClickListener(ClickListener listener)
Adds a listener interface to receive click events. |
void |
addFocusListener(FocusListener listener)
Adds a listener interface to receive mouse events. |
void |
addKeyboardListener(KeyboardListener listener)
Adds a listener interface to receive keyboard events. |
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. |
void |
removeChangeListener(ChangeListener listener)
Removes a previously added listener interface. |
void |
removeClickListener(ClickListener listener)
Removes a previously added listener interface. |
void |
removeFocusListener(FocusListener listener)
Removes a previously added listener interface. |
void |
removeKeyboardListener(KeyboardListener listener)
Removes a previously added listener interface. |
void |
setAccessKey(char key)
Sets the widget's 'access key'. |
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 |
setTabIndex(int index)
Sets the widget's position in the tab index. |
void |
setText(java.lang.String text)
Sets this object's text. |
Methods inherited from class com.google.gwt.user.client.ui.Composite |
getElement, getWidget, initWidget, onAttach, onDetach, setWidget |
Methods inherited from class com.google.gwt.user.client.ui.Widget |
getParent, isAttached, onBrowserEvent, onLoad, onUnload, removeFromParent, setElement |
Methods inherited from class com.google.gwt.user.client.ui.UIObject |
addStyleName, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getTitle, isVisible, isVisible, removeStyleName, resetStyleName, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setTitle, setVisible, setVisible, setWidth, sinkEvents, toString, unsinkEvents |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
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 widgetMethod Detail |
public final void addChangeListener(ChangeListener listener)
SourcesChangeEvents
addChangeListener
in interface SourcesChangeEvents
listener
- the listener interface to addpublic final void addClickListener(ClickListener listener)
SourcesClickEvents
addClickListener
in interface SourcesClickEvents
listener
- the listener interface to addpublic final void addFocusListener(FocusListener listener)
SourcesFocusEvents
addFocusListener
in interface SourcesFocusEvents
listener
- the listener interface to addpublic final void addKeyboardListener(KeyboardListener listener)
SourcesKeyboardEvents
addKeyboardListener
in interface SourcesKeyboardEvents
listener
- the listener interface to addpublic final int getLimit()
SuggestOracle
to enforce this
limit.
public final SuggestOracle getSuggestOracle()
SuggestOracle
.
SuggestOracle
public final int getTabIndex()
HasFocus
getTabIndex
in interface HasFocus
public final java.lang.String getText()
HasText
getText
in interface HasText
public final void removeChangeListener(ChangeListener listener)
SourcesChangeEvents
removeChangeListener
in interface SourcesChangeEvents
listener
- the listener interface to removepublic final void removeClickListener(ClickListener listener)
SourcesClickEvents
removeClickListener
in interface SourcesClickEvents
listener
- the listener interface to removepublic final void removeFocusListener(FocusListener listener)
SourcesFocusEvents
removeFocusListener
in interface SourcesFocusEvents
listener
- the listener interface to removepublic final void removeKeyboardListener(KeyboardListener listener)
SourcesKeyboardEvents
removeKeyboardListener
in interface SourcesKeyboardEvents
listener
- the listener interface to removepublic final void setAccessKey(char key)
HasFocus
setAccessKey
in interface HasFocus
key
- the widget's access keypublic final void setFocus(boolean focused)
HasFocus
setFocus
in interface HasFocus
focused
- whether this widget should take focus or release itpublic final void setLimit(int limit)
limit
- the limit to the number of suggestions providedpublic final void setTabIndex(int index)
HasFocus
-1
will cause this widget to
be removed from the tab order.
setTabIndex
in interface HasFocus
index
- the widget's tab indexpublic final void setText(java.lang.String text)
HasText
setText
in interface HasText
text
- the object's new text
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |