public class ToggleButton extends CustomButton implements HasValue<Boolean>, IsEditor<LeafValueEditor<Boolean>>
ToggleButton
is a stylish stateful button which allows the
user to toggle between up
and down
states.
CustomButton.Face
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
DEBUG_ID_PREFIX
Constructor and Description |
---|
ToggleButton()
Constructor for
ToggleButton . |
ToggleButton(Image upImage)
Constructor for
ToggleButton . |
ToggleButton(Image upImage,
ClickHandler handler)
Constructor for
ToggleButton . |
ToggleButton(Image upImage,
ClickListener listener)
Deprecated.
Use
ToggleButton(Image, ClickHandler) instead |
ToggleButton(Image upImage,
Image downImage)
Constructor for
ToggleButton . |
ToggleButton(Image upImage,
Image downImage,
ClickHandler handler)
Constructor for
ToggleButton . |
ToggleButton(Image upImage,
Image downImage,
ClickListener listener)
Deprecated.
Use
ToggleButton(Image, Image, ClickHandler) instead |
ToggleButton(String upText)
Constructor for
ToggleButton . |
ToggleButton(String upText,
ClickHandler handler)
Constructor for
ToggleButton . |
ToggleButton(String upText,
ClickListener listener)
Deprecated.
Use
ToggleButton(String, ClickHandler) instead |
ToggleButton(String upText,
String downText)
Constructor for
ToggleButton . |
ToggleButton(String upText,
String downText,
ClickHandler handler)
Constructor for
ToggleButton . |
Modifier and Type | Method and Description |
---|---|
HandlerRegistration |
addValueChangeHandler(ValueChangeHandler<Boolean> handler)
Adds a
ValueChangeEvent handler. |
LeafValueEditor<Boolean> |
asEditor()
Returns the Editor encapsulated by the view object.
|
Boolean |
getValue()
Determines whether this button is currently down.
|
boolean |
isDown()
Is this button down?
|
protected void |
onClick()
Called when the user finishes clicking on this button.
|
void |
setDown(boolean down)
Sets whether this button is down.
|
void |
setValue(Boolean value)
Sets whether this button is down.
|
void |
setValue(Boolean value,
boolean fireEvents)
Sets whether this button is down, firing
ValueChangeEvent if
appropriate. |
getDownDisabledFace, getDownFace, getDownHoveringFace, getHTML, getTabIndex, getText, getUpDisabledFace, getUpFace, getUpHoveringFace, onAttach, onBrowserEvent, onClickCancel, onClickStart, onDetach, setAccessKey, setEnabled, setFocus, setHTML, setHTML, setTabIndex, setText
addBlurHandler, addClickHandler, addClickListener, addDoubleClickHandler, addDragEndHandler, addDragEnterHandler, addDragHandler, addDragLeaveHandler, addDragOverHandler, addDragStartHandler, addDropHandler, addFocusHandler, addFocusListener, addGestureChangeHandler, addGestureEndHandler, addGestureStartHandler, addKeyboardListener, addKeyDownHandler, addKeyPressHandler, addKeyUpHandler, addMouseDownHandler, addMouseListener, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler, addMouseWheelListener, addTouchCancelHandler, addTouchEndHandler, addTouchMoveHandler, addTouchStartHandler, getFocusImpl, isEnabled, removeClickListener, removeFocusListener, removeKeyboardListener, removeMouseListener, removeMouseWheelListener
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
fireEvent
public ToggleButton()
ToggleButton
.public ToggleButton(Image upImage)
ToggleButton
. The supplied image is used to
construct the default face.upImage
- image for the default face of the buttonpublic ToggleButton(Image upImage, ClickHandler handler)
ToggleButton
. The supplied image is used to
construct the default face of the button.upImage
- image for the default (up) face of the buttonhandler
- the click handler@Deprecated public ToggleButton(Image upImage, ClickListener listener)
ToggleButton(Image, ClickHandler)
insteadToggleButton
. The supplied image is used to
construct the default face of the button.upImage
- image for the default (up) face of the buttonlistener
- the click listenerpublic ToggleButton(Image upImage, Image downImage)
ToggleButton
.upImage
- image for the default(up) face of the buttondownImage
- image for the down face of the buttonpublic ToggleButton(Image upImage, Image downImage, ClickHandler handler)
ToggleButton
.upImage
- image for the default(up) face of the buttondownImage
- image for the down face of the buttonhandler
- the click handler@Deprecated public ToggleButton(Image upImage, Image downImage, ClickListener listener)
ToggleButton(Image, Image, ClickHandler)
insteadToggleButton
.upImage
- image for the default(up) face of the buttondownImage
- image for the down face of the buttonlistener
- clickListenerpublic ToggleButton(String upText)
ToggleButton
. The supplied text is used to
construct the default face of the button.upText
- the text for the default (up) face of the button.public ToggleButton(String upText, ClickHandler handler)
ToggleButton
. The supplied text is used to
construct the default face of the button.upText
- the text for the default (up) face of the buttonhandler
- the click handler@Deprecated public ToggleButton(String upText, ClickListener listener)
ToggleButton(String, ClickHandler)
insteadToggleButton
. The supplied text is used to
construct the default face of the button.upText
- the text for the default (up) face of the buttonlistener
- the click listenerpublic ToggleButton(String upText, String downText)
ToggleButton
.upText
- the text for the default (up) face of the buttondownText
- the text for down face of the buttonpublic ToggleButton(String upText, String downText, ClickHandler handler)
ToggleButton
.upText
- the text for the default (up) face of the buttondownText
- the text for down face of the buttonhandler
- the click handlerpublic HandlerRegistration addValueChangeHandler(ValueChangeHandler<Boolean> handler)
HasValueChangeHandlers
ValueChangeEvent
handler.addValueChangeHandler
in interface HasValueChangeHandlers<Boolean>
handler
- the handlerpublic LeafValueEditor<Boolean> asEditor()
IsEditor
asEditor
in interface IsEditor<LeafValueEditor<Boolean>>
Editor
of type Epublic Boolean getValue()
getValue
in interface TakesValue<Boolean>
getValue
in interface HasValue<Boolean>
true
if the button is pressed, false otherwise. Will
not return nullTakesValue.setValue(V)
public boolean isDown()
CustomButton
isDown
in class CustomButton
true
if the button is downpublic void setDown(boolean down)
ValueChangeEvent
. (If you want the
event to fire, use setValue(Boolean, boolean)
)setDown
in class CustomButton
down
- true
to press the button, false
otherwisepublic void setValue(Boolean value)
setValue
in interface TakesValue<Boolean>
setValue
in interface HasValue<Boolean>
value
- true to press the button, false otherwise; null value implies
falseTakesValue.getValue()
public void setValue(Boolean value, boolean fireEvents)
ValueChangeEvent
if
appropriate.setValue
in interface HasValue<Boolean>
value
- true to press the button, false otherwise; null value implies
falsefireEvents
- If true, and value has changed, fire a
ValueChangeEvent
protected void onClick()
CustomButton
CustomButton.onClickStart()
should override this method to restore the normal
widget display.onClick
in class CustomButton
Copyright © 2018. All rights reserved.