Class WAbstractToggleButton
- Direct Known Subclasses:
WCheckBox
,WRadioButton
public abstract class WAbstractToggleButton extends WFormWidget
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
Constructors Modifier Constructor Description protected
WAbstractToggleButton()
Creates an unchecked toggle button without label.protected
WAbstractToggleButton(WContainerWidget parent)
Creates an unchecked toggle button without label.protected
WAbstractToggleButton(java.lang.CharSequence text)
Creates an unchecked toggle button with given text label.protected
WAbstractToggleButton(java.lang.CharSequence text, WContainerWidget parent)
Creates an unchecked toggle button with given text label. -
Method Summary
Modifier and Type Method Description EventSignal
checked()
Signal emitted when the button gets checked.WString
getText()
Returns the label text.TextFormat
getTextFormat()
Returns the text format.java.lang.String
getValueText()
Returns the current value.boolean
isChecked()
Returns the button state.boolean
isWordWrap()
Returns whether word wrapping is on.void
refresh()
Refresh the widget.void
remove()
Destructor.void
setChecked()
Checks the button.void
setChecked(boolean how)
Sets the button state.protected void
setFormData(WObject.FormData formData)
void
setText(java.lang.CharSequence text)
Sets the label text.boolean
setTextFormat(TextFormat format)
Sets the text format.void
setUnChecked()
Unchecks the button.void
setValueText(java.lang.String text)
Sets the current value.void
setWordWrap(boolean wordWrap)
Configures word wrapping.EventSignal
unChecked()
Signal emitted when the button gets un-checked.Methods inherited from class eu.webtoolkit.jwt.WFormWidget
changed, enableAjax, getEmptyText, getLabel, getPlaceholderText, getTabIndex, getValidator, isCanReceiveFocus, isReadOnly, propagateSetEnabled, render, selected, setEmptyText, setEnabled, setHidden, setPlaceholderText, setReadOnly, setToolTip, setValidator, validate, validated
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, 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, jsStringLiteral, jsStringLiteral, parentResized, parentResized, propagateSetVisible, removeScript, removeStyleClass, resize, scrollVisibilityChanged, setAttributeValue, setBaseZIndex, setCanReceiveFocus, setClearSides, setDecorationStyle, setDeferredToolTip, setDisabled, setFloatSide, setFocus, setHiddenKeepsGeometry, setHtmlTagName, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setOffsets, setPositionScheme, setScrollVisibilityEnabled, setScrollVisibilityMargin, setSelectable, setStyleClass, setTabIndex, setThemeStyleEnabled, setVerticalAlignment, updateSignalConnection, voidEventSignal
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, isLayoutSizeAware, layoutSizeChanged, needsRerender, positionAt, positionAt, removeChild, removeStyleClass, render, resize, scheduleRender, scheduleRender, scheduleRender, setClearSides, setDeferredToolTip, setFocus, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setObjectName, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
Methods inherited from class eu.webtoolkit.jwt.WObject
addChild, getObjectName
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
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
protected WAbstractToggleButton(java.lang.CharSequence text)Creates an unchecked toggle button with given text label.
-
-
Method Details
-
remove
public void remove()Destructor.- Overrides:
remove
in classWFormWidget
- See Also:
WContainerWidget.removeWidget(WWidget widget)
-
setText
public void setText(java.lang.CharSequence text)Sets the label text.The label is rendered to the right of the button.
-
getText
Returns the label text.- See Also:
setText(CharSequence text)
-
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.XHTMLText
, 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.PlainText
. -
getTextFormat
Returns the text format.- See Also:
setTextFormat(TextFormat format)
-
isChecked
public boolean isChecked()Returns the button state.- See Also:
setChecked()
-
setChecked
public void setChecked(boolean how)Sets the button state.This method does not emit one of the
checked()
orunChecked()
signals.- See Also:
setChecked()
,setUnChecked()
-
setChecked
public void setChecked()Checks the button.Does not emit the
checked()
signal.- See Also:
setChecked(boolean how)
-
setUnChecked
public void setUnChecked()Unchecks the button.Does not emit the
unChecked()
signal.- See Also:
setChecked(boolean how)
-
getValueText
public java.lang.String getValueText()Returns the current value.Returns "yes" when checked, "maybe" when partially checked, and "no" when unchecked.
- Specified by:
getValueText
in classWFormWidget
-
setValueText
public void setValueText(java.lang.String text)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 to any change of 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 to any change of the button state. -
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.PlainText
) or <br /> tags or other block-level tags (forTextFormat.XHTMLText
).The default value is
false
.- See Also:
isWordWrap()
-
isWordWrap
public boolean isWordWrap()Returns whether word wrapping is on.- See Also:
setWordWrap(boolean wordWrap)
-
setFormData
- Overrides:
setFormData
in classWObject
-