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_, noDefaultFields inherited from class eu.webtoolkit.jwt.WWidget
WT_GETEXTRAMS_JS -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates an unchecked toggle button without label.protectedWAbstractToggleButton(WContainerWidget parentContainer) Creates an unchecked toggle button without label.protectedCreates an unchecked toggle button with given text label.protectedWAbstractToggleButton(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.booleanReturns the button state.booleanReturns whether word wrapping is on.voidrefresh()Refresh the widget.voidremove()Destructor.voidChecks the button.voidsetChecked(boolean how) Sets the button state.protected voidsetFormData(WObject.FormData formData) voidsetText(CharSequence text) Sets the label text.booleansetTextFormat(TextFormat format) Sets the text format.voidUnchecks the button.voidsetValueText(String text) Sets the current value.voidsetWordWrap(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, getRealValidator, getTabIndex, getValidator, hasValidatorChanged, isCanReceiveFocus, isReadOnly, propagateSetEnabled, render, setEnabled, setHidden, setPlaceholderText, setReadOnly, setToolTip, setValidator, validate, validated, validatorChangedMethods 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, unsetDraggableMethods inherited from class eu.webtoolkit.jwt.WWebWidget
addStyleClass, beingDeleted, blurred, callJavaScriptMember, childrenChanged, createDomElement, doJavaScript, escapeText, escapeText, escapeText, escapeText, find, findById, focussed, formDataChanged, 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, hideToolTip, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isScrollVisibilityEnabled, isScrollVisible, isSetFirstFocus, isThemeStyleEnabled, isVisible, iterateChildren, jsStringLiteral, jsStringLiteral, manageWidget, parentResized, parentResized, propagateSetVisible, removeScript, removeStyleClass, resendFormData, 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, showToolTip, showToolTipOnHover, unescapeText, updateSignalConnection, voidEventSignal, widgetAdded, widgetRemovedMethods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, applyThemeStyles, boxBorder, boxPadding, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, layoutSizeChanged, needsRerender, positionAt, positionAt, positionAt, positionAt, removeFromParent, removeStyleClass, removeWidget, render, resize, scheduleRender, scheduleRender, scheduleRender, scheduleThemeStyleApply, setClearSides, setDeferredToolTip, setFocus, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, trMethods 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:
removein 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:
getValueTextin classWFormWidget
-
setValueText
Sets the current value.This interprets text values of "yes", "maybe" or "no".
- Specified by:
setValueTextin 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. SinceEventSignalmirrors 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:WWidgetRefresh 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:
refreshin classWFormWidget
-
setWordWrap
public void setWordWrap(boolean wordWrap) Configures word wrapping.When
wordWrapistrue, the widget may break lines, creating a multi-line text. WhenwordWrapisfalse, 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:
setFormDatain classWObject
-