|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecteu.webtoolkit.jwt.WObject
eu.webtoolkit.jwt.WWidget
eu.webtoolkit.jwt.WWebWidget
eu.webtoolkit.jwt.WInteractWidget
eu.webtoolkit.jwt.WFormWidget
eu.webtoolkit.jwt.WComboBox
public class WComboBox
A widget that provides a drop-down combo-box control.
A combo box provides the user with a set of options, from which one option may be selected.
WComboBox is an MVC view class, using a simple string list model by default.
The model may be populated using addItem() or insertItem() and the contents can be cleared through
clear(). These methods manipulate the underlying
getModel().
To use the combo box with a custom model instead of the default
WStringListModel, use
setModel().
To react to selection events, connect to the WFormWidget#changed(), activated() or
sactivated() signals.
At all times, the current selection index is available through
getCurrentIndex() and the current
selection text using getCurrentText().
WComboBox does not have support for auto-completion, this behaviour
can be found in the WSuggestionPopup.
WComboBox is an inline widget.
The widget corresponds to the HTML <select> tag and does
not provide styling. It can be styled using inline or external CSS as
appropriate.
| Constructor Summary | |
|---|---|
WComboBox()
Creates an empty combo-box with optional parent. |
|
WComboBox(WContainerWidget parent)
Creates an empty combo-box with optional parent. |
|
| Method Summary | |
|---|---|
Signal1<java.lang.Integer> |
activated()
Signal emitted when the selection changed. |
void |
addItem(java.lang.CharSequence text)
Adds an option item. |
void |
clear()
Clears all items. |
int |
findText(java.lang.CharSequence text,
MatchOptions flags)
Returns the index of the first item that matches a text. |
int |
getCount()
Returns the number of items. |
int |
getCurrentIndex()
Returns the currently selected item. |
WString |
getCurrentText()
Returns the text of the currently selected item. |
WString |
getItemText(int index)
Returns the text of a particular item. |
WAbstractItemModel |
getModel()
Returns the data model. |
java.lang.String |
getValueText()
Returns the current value. |
void |
insertItem(int index,
java.lang.CharSequence text)
Inserts an item at the specified position. |
void |
refresh()
Refresh the widget. |
void |
removeItem(int index)
Removes the item at the specified position. |
Signal1<WString> |
sactivated()
Signal emitted when the selection changed. |
void |
setCurrentIndex(int index)
Changes the current selection. |
void |
setItemText(int index,
java.lang.CharSequence text)
Changes the text for a specified option. |
void |
setModel(WAbstractItemModel model)
Sets the model to be used for the items. |
void |
setModelColumn(int index)
Sets the column in the model to be used for the items. |
void |
setValueText(java.lang.String value)
Sets the current value. |
| Methods inherited from class eu.webtoolkit.jwt.WFormWidget |
|---|
blurred, changed, enableAjax, focussed, getEmptyText, getLabel, getTabIndex, getValidator, hasFocus, isReadOnly, propagateSetEnabled, remove, render, selected, setEmptyText, setEnabled, setFocus, setFocus, setHidden, setReadOnly, setTabIndex, setValidator, validate, validated |
| Methods inherited from class eu.webtoolkit.jwt.WInteractWidget |
|---|
clicked, doubleClicked, enterPressed, escapePressed, gestureChanged, gestureEnded, gestureStarted, isEnabled, keyPressed, keyWentDown, keyWentUp, load, mouseDragged, mouseMoved, mouseWentDown, mouseWentOut, mouseWentOver, mouseWentUp, mouseWheel, setDraggable, setDraggable, setDraggable, setDraggable, touchEnded, touchMoved, touchStarted |
| Methods inherited from class eu.webtoolkit.jwt.WWidget |
|---|
acceptDrops, acceptDrops, addCssRule, addCssRule, addStyleClass, animateHide, animateShow, boxBorder, boxPadding, containsExposed, disable, dropEvent, enable, getDrop, getJsRef, getParent, hide, htmlText, isLayoutSizeAware, layoutSizeChanged, positionAt, positionAt, removeStyleClass, resize, setClearSides, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr |
| Methods inherited from class eu.webtoolkit.jwt.WObject |
|---|
addChild, getObjectName, setObjectName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WComboBox(WContainerWidget parent)
public WComboBox()
Calls this((WContainerWidget)null)
| Method Detail |
|---|
public void addItem(java.lang.CharSequence text)
Equivalent to insertItem (getCount(), text).
public int getCount()
public int getCurrentIndex()
If no item is currently selected, the method returns -1.
The default value is 0, unless the combo box is empty.
public void insertItem(int index,
java.lang.CharSequence text)
The item is inserted in the underlying model at position
index. This requires that the getModel() is editable.
addItem(CharSequence text),
removeItem(int index)public void removeItem(int index)
The item is removed from the underlying model. This requires that the
getModel() is editable.
insertItem(int index, CharSequence text),
clear()public void setCurrentIndex(int index)
Specify a value of -1 for index to clear the selection.
public void setItemText(int index,
java.lang.CharSequence text)
The text for the item at position index is changed. This
requires that the getModel() is editable.
public WString getCurrentText()
getCurrentIndex(),
getItemText(int index)public WString getItemText(int index)
setItemText(int index, CharSequence text),
getCurrentText()public void setModel(WAbstractItemModel model)
The model may not be 0, and ownership of the model is not
transferred.
The default value is a WStringListModel that is owned by the
combo box.
setModelColumn(int index)public void setModelColumn(int index)
The column index in the model will be used to retrieve data.
The default value is 0.
setModel(WAbstractItemModel model)public WAbstractItemModel getModel()
setModel(WAbstractItemModel model)
public int findText(java.lang.CharSequence text,
MatchOptions flags)
public java.lang.String getValueText()
Returns getCurrentText().
getValueText in class WFormWidgetpublic void setValueText(java.lang.String value)
Sets the current index to the item corresponding to value.
setValueText in class WFormWidgetpublic void refresh()
WWidget
The refresh method is invoked when the locale is changed using
WApplication#setLocale() or
when the user hit the refresh button.
The widget must actualize its contents in response.
refresh in class WFormWidgetpublic void clear()
Removes all items from the underlying model. This requires that the
getModel() is editable.
public Signal1<java.lang.Integer> activated()
The newly selected item is passed as an argument.
sactivated(),
getCurrentIndex()public Signal1<WString> sactivated()
The newly selected text is passed as an argument.
activated(),
getCurrentText()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||