Class WAbstractToggleButton
- Direct Known Subclasses:
WCheckBox
,WRadioButton
A toggle button provides a button with a boolean state (checked or unchecked), and a text label.
To act on a change of the state, either connect a slot to the WFormWidget.changed()
signal, or connect a slot to the checked()
or unChecked()
signals.
The current state (checked or unchecked) may be inspected using the isChecked()
method.
-
Nested Class Summary
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
Field Summary
Fields inherited from class eu.webtoolkit.jwt.WInteractWidget
dragTouchEndSlot_, dragTouchSlot_
-
Constructor Summary
ModifierConstructorDescriptionprotected
Creates an unchecked toggle button without label.protected
WAbstractToggleButton
(WContainerWidget parentContainer) Creates an unchecked toggle button without label.protected
Creates an unchecked toggle button with given text label.protected
WAbstractToggleButton
(CharSequence text, WContainerWidget parentContainer) Creates an unchecked toggle button with given text label. -
Method Summary
Modifier and TypeMethodDescriptionchecked()
Signal emitted when the button gets checked.getText()
Returns the label text.Returns the text format.Returns the current value.boolean
Returns the button state.boolean
Returns whether word wrapping is on.void
refresh()
Refresh the widget.void
remove()
Destructor.void
Checks the button.void
setChecked
(boolean how) Sets the button state.protected void
setFormData
(WObject.FormData formData) void
setText
(CharSequence text) Sets the label text.boolean
setTextFormat
(TextFormat format) Sets the text format.void
Unchecks the button.void
setValueText
(String text) Sets the current value.void
setWordWrap
(boolean wordWrap) Configures word wrapping.Signal emitted when the button gets un-checked.Methods inherited from class eu.webtoolkit.jwt.WFormWidget
changed, enableAjax, getLabel, getPlaceholderText, getTabIndex, getValidator, isCanReceiveFocus, isReadOnly, propagateSetEnabled, render, setEnabled, setHidden, setPlaceholderText, setReadOnly, setToolTip, setValidator, validate, validated, validatorChanged
Methods inherited from class eu.webtoolkit.jwt.WInteractWidget
clicked, doubleClicked, enterPressed, escapePressed, gestureChanged, gestureEnded, gestureStarted, getMouseOverDelay, isEnabled, keyPressed, keyWentDown, keyWentUp, load, mouseDragged, mouseMoved, mouseWentDown, mouseWentOut, mouseWentOver, mouseWentUp, mouseWheel, setDraggable, setDraggable, setDraggable, setDraggable, setMouseOverDelay, setPopup, touchEnded, touchMoved, touchStarted, unsetDraggable
Methods inherited from class eu.webtoolkit.jwt.WWebWidget
addStyleClass, beingDeleted, blurred, callJavaScriptMember, childrenChanged, createDomElement, doJavaScript, escapeText, escapeText, escapeText, escapeText, find, findById, focussed, getAttributeValue, getBaseZIndex, getChildren, getClearSides, getDecorationStyle, getDomChanges, getFloatSide, getHeight, getHtmlTagName, getId, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getScrollVisibilityMargin, getStyleClass, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, hasFocus, hasStyleClass, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isScrollVisibilityEnabled, isScrollVisible, isSetFirstFocus, isThemeStyleEnabled, isVisible, iterateChildren, jsStringLiteral, jsStringLiteral, manageWidget, parentResized, parentResized, propagateSetVisible, removeScript, removeStyleClass, resize, scrollVisibilityChanged, setAttributeValue, setBaseZIndex, setCanReceiveFocus, setClearSides, setDecorationStyle, setDeferredToolTip, setDisabled, setFlexBox, setFloatSide, setFocus, setHiddenKeepsGeometry, setHtmlTagName, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setObjectName, setOffsets, setParentWidget, setPositionScheme, setScrollVisibilityEnabled, setScrollVisibilityMargin, setSelectable, setStyleClass, setTabIndex, setThemeStyleEnabled, setVerticalAlignment, unescapeText, updateSignalConnection, voidEventSignal, widgetAdded, widgetRemoved
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, boxBorder, boxPadding, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, layoutSizeChanged, needsRerender, positionAt, positionAt, removeFromParent, removeStyleClass, removeWidget, render, resize, scheduleRender, scheduleRender, scheduleRender, setClearSides, setDeferredToolTip, setFocus, 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
getObjectName
-
Constructor Details
-
WAbstractToggleButton
Creates an unchecked toggle button without label. -
WAbstractToggleButton
protected WAbstractToggleButton()Creates an unchecked toggle button without label. -
WAbstractToggleButton
Creates an unchecked toggle button with given text label.The text label is rendered to the right side of the button.
-
WAbstractToggleButton
Creates an unchecked toggle button with given text label.
-
-
Method Details
-
remove
public void remove()Destructor.- Overrides:
remove
in classWFormWidget
- See Also:
-
setText
Sets the label text.The label is rendered to the right of the button.
-
getText
Returns the label text.- See Also:
-
setTextFormat
Sets the text format.The textFormat controls how the string should be interpreted: either as plain text, which is displayed literally, or as XHTML-markup.
When changing the textFormat to
TextFormat.XHTML
, and the current text is literal (not created usingWString#tr()
), the current text is parsed using an XML parser which discards malicious tags and attributes silently. When the parser encounters an XML parse error, the textFormat is left unchanged, and this method returns false.Returns whether the textFormat could be set for the current text.
The default format is
TextFormat.Plain
. -
getTextFormat
Returns the text format.- See Also:
-
isChecked
public boolean isChecked()Returns the button state.- See Also:
-
setChecked
public void setChecked(boolean how) Sets the button state.This method does not emit one of the
checked()
orunChecked()
signals.- See Also:
-
setChecked
public void setChecked()Checks the button.Does not emit the
checked()
signal.- See Also:
-
setUnChecked
public void setUnChecked()Unchecks the button.Does not emit the
unChecked()
signal.- See Also:
-
getValueText
Returns the current value.Returns "yes" when checked, "maybe" when partially checked, and "no" when unchecked.
- Specified by:
getValueText
in classWFormWidget
-
setValueText
Sets the current value.This interprets text values of "yes", "maybe" or "no".
- Specified by:
setValueText
in classWFormWidget
-
checked
Signal emitted when the button gets checked.This signal is emitted when the user checks the button.
You can use the
WFormWidget.changed()
signal to react when the user makes any change to the button state. -
unChecked
Signal emitted when the button gets un-checked.This signal is emitted when the user unchecks the button.
You can use the
WFormWidget.changed()
signal to react when the user makes any change to the button state.Remark: This signal is not emitted for
WRadioButton
. In this case a button can only be unchecked because another button is checked. The browser will only generate an event for the button which was checked. SinceEventSignal
mirrors browser events, JWt will also not emit this signal. The functionWButtonGroup.checkedChanged()
might be easier to use in this case. -
refresh
public void refresh()Description copied from class:WWidget
Refresh the widget.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.
Note: This does not rerender the widget! Calling
refresh()
usually does not have any effect (unless you've reimplementedrefresh()
to attach to it an effect).- Overrides:
refresh
in classWFormWidget
-
setWordWrap
public void setWordWrap(boolean wordWrap) Configures word wrapping.When
wordWrap
istrue
, the widget may break lines, creating a multi-line text. WhenwordWrap
isfalse
, the text will displayed on a single line, unless the text contains end-of-lines (forTextFormat.Plain
) or <br /> tags or other block-level tags (forTextFormat.XHTML
).The default value is
false
.- See Also:
-
isWordWrap
public boolean isWordWrap()Returns whether word wrapping is on.- See Also:
-
setFormData
- Overrides:
setFormData
in classWObject
-