Class WPushButton
To act on a button click, connect a slot to the WInteractWidget.clicked() signal.
WPushButton is an inline widget.
CSS
The widget corresponds to the HTML <button> tag (with some exceptions in
the bootstrap theme).
-
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
ConstructorsConstructorDescriptionCreates a push button.WPushButton(WContainerWidget parentContainer) Creates a push button.WPushButton(CharSequence text) Creates a push button with given label text.WPushButton(CharSequence text, TextFormat format) Creates a push button with given label text.WPushButton(CharSequence text, TextFormat format, WContainerWidget parentContainer) Creates a push button with given label text.WPushButton(CharSequence text, WContainerWidget parentContainer) Creates a push button with given label text. -
Method Summary
Modifier and TypeMethodDescriptionchecked()Signal emitted when the button gets checked.protected voidProgresses to an Ajax-enabled widget.getBadge()Returns the badge.protected voidgetDomChanges(List<DomElement> result, WApplication app) Get DOM changes for this widget.getIcon()Returns the icon.getLink()Returns the destination link.getMenu()Returns an associated popup menu.getText()Returns the button text.Returns the text format.Returns the current value.booleanReturns whether a button is checkable.booleanReturns the button state.booleanReturns whether the button is a default button.booleanSet focus on the widget's first descendant.voiditerateChildren(HandleWidgetMethod method) protected voidpropagateSetEnabled(boolean enabled) Propagates that a widget was enabled or disabled through children.voidrefresh()Refresh the widget.voidremove()Destructor.removeWidget(WWidget widget) Removes a child widget.voidSets a badge.voidsetCheckable(boolean checkable) Sets whether the button is checkable.voidChecks the button.voidsetChecked(boolean checked) Sets the button state.voidsetDefault(boolean enabled) Sets the default property.voidSets an icon.voidSets a destination link.voidsetMenu(WPopupMenu popupMenu) Links a popup menu to the button.booleansetText(CharSequence text) Sets the button text.booleansetTextFormat(TextFormat textFormat) Sets the text format.voidUnchecks the button.voidsetValueText(String value) Sets the current value.Signal emitted when the button gets unchecked.Methods inherited from class eu.webtoolkit.jwt.WFormWidget
changed, getLabel, getPlaceholderText, getRealValidator, getTabIndex, getValidator, hasValidatorChanged, isCanReceiveFocus, isReadOnly, 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, 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, isThemeStyleEnabled, isVisible, 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, isExposed, isGlobalWidget, isLayoutSizeAware, layoutSizeChanged, needsRerender, positionAt, positionAt, positionAt, positionAt, removeFromParent, removeStyleClass, 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, setFormData
-
Constructor Details
-
WPushButton
Creates a push button. -
WPushButton
public WPushButton()Creates a push button. -
WPushButton
Creates a push button with given label text.The default text format is
TextFormat.Plain. -
WPushButton
Creates a push button with given label text. -
WPushButton
Creates a push button with given label text. -
WPushButton
Creates a push button with given label text.
-
-
Method Details
-
remove
public void remove()Description copied from class:WFormWidgetDestructor.- Overrides:
removein classWFormWidget- See Also:
-
setDefault
public void setDefault(boolean enabled) Sets the default property.This has only a functional meaning for a button in a dialog footer, as it becomes associated with pressing 'enter' in the dialog.
A default button may be rendered in a different style, depending on the theme.
-
isDefault
public boolean isDefault()Returns whether the button is a default button.- See Also:
-
setCheckable
public void setCheckable(boolean checkable) Sets whether the button is checkable.A checkable button can be checked and unchecked, and clicking will toggle between these two states.
- See Also:
-
isCheckable
public boolean isCheckable()Returns whether a button is checkable.- See Also:
-
setChecked
public void setChecked(boolean checked) Sets the button state.This is ignored for a button which is not checkable.
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:
-
isChecked
public boolean isChecked()Returns the button state.- See Also:
-
setText
Sets the button text.The default text format is
TextFormat.Plain.When the current text format is
TextFormat.XHTML, andtextis literal (not created usingWString#tr()), it is parsed using an XML parser which discards malicious tags and attributes silently. When the parser encounters an XML parse error, the textFormat is changed toTextFormat.Plain. Iftextis not a literal, the same parser is applied only when the text is resolved.Returns whether the text could be set using the current textFormat. A return value of
falseindicates that the text format was changed in order to be able to accept the new text.- See Also:
-
getText
Returns the button 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:
-
setIcon
Sets an icon.The icon is placed to the left of the text.
-
getIcon
Returns the icon.- See Also:
-
setBadge
Sets a badge.To remove the badge again, call this function with
null.- See Also:
-
getBadge
Returns the badge.- See Also:
-
setLink
Sets a destination link.This method can be used to make the button behave like a
WAnchor(or conversely, an anchor look like a button) and redirect to another URL when clicked.The
linkmay be to a URL, a resource, or an internal path.By default, a button does not link to an URL and you should listen to the
WInteractWidget.clicked()signal to react to a click event.Warning: In Bootstrap theme, you should set a link before it's rendered since it commit's the button to be rendered as an anchor. (see also http://redmine.emweb.be/issues/1802).
-
getLink
Returns the destination link.- See Also:
-
getValueText
Returns the current value.Returns an empty string, since a button has no value.
- Specified by:
getValueTextin classWFormWidget
-
setValueText
Sets the current value.Has no effect, since a button has not value.
- Specified by:
setValueTextin classWFormWidget
-
setMenu
Links a popup menu to the button.When the button is clicked, the linked popup menu is shown.
-
getMenu
Returns an associated popup menu.- See Also:
-
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
-
checked
Signal emitted when the button gets checked.This signal is emitted when the user checks the button.
You can use the
WInteractWidget.clicked()signal to react to any change of the button state.- See Also:
-
unChecked
Signal emitted when the button gets unchecked.This signal is emitted when the user unchecks the button.
You can use the
WInteractWidget.clicked()signal to react to any change of the button state.- See Also:
-
isSetFirstFocus
public boolean isSetFirstFocus()Description copied from class:WWidgetSet focus on the widget's first descendant.Set focus on the widget itself, or on a first descendant which can receive focus.
Returns whether focus could be set.
- Overrides:
isSetFirstFocusin classWWebWidget
-
iterateChildren
- Overrides:
iterateChildrenin classWWebWidget
-
removeWidget
Description copied from class:WWidgetRemoves a child widget.- Overrides:
removeWidgetin classWWidget
-
getDomChanges
Description copied from class:WWebWidgetGet DOM changes for this widget.This is an internal function, and should not be called directly, or be overridden!
- Overrides:
getDomChangesin classWWebWidget
-
propagateSetEnabled
protected void propagateSetEnabled(boolean enabled) Description copied from class:WWidgetPropagates that a widget was enabled or disabled through children.When enabling or disabling a widget, you usually also want to disable contained children. This method is called by
setDisabled()to propagate its state to all children.You may want to reimplement this method if they wish to render differently when a widget is disabled. The default implementation will propagate the signal to all children.
- Overrides:
propagateSetEnabledin classWFormWidget
-
enableAjax
protected void enableAjax()Description copied from class:WWidgetProgresses to an Ajax-enabled widget.This method is called when the progressive bootstrap method is used, and support for AJAX has been detected. The default behavior will upgrade the widget's event handling to use AJAX instead of full page reloads, and propagate the call to its children.
You may want to reimplement this method if you want to make changes to widget when AJAX is enabled. You should always call the base implementation.
- Overrides:
enableAjaxin classWFormWidget- See Also:
-