public abstract class CustomButton extends ButtonBase
down-hovering
face, the button's style is
gwt-PushButton-down-hovering. The overall style name can be used to
change the style of the button irrespective of the current face.
Each button face can be assigned is own image, text, or html contents. If no
content is defined for a face, then the face will use the contents of another
face. For example, if down-hovering
does not have defined
contents, it will use the contents defined by the down
face.
The supported faces are defined below:
CSS style name | Getter method | description of face | defaults to contents of face |
up | getUpFace() |
face shown when button is up | none |
down | getDownFace() |
face shown when button is down | up |
up-hovering | getUpHoveringFace() |
face shown when button is up and hovering | up |
up-disabled | getUpDisabledFace() |
face shown when button is up and disabled | up |
down-hovering | getDownHoveringFace() |
face shown when button is down and hovering | down |
down-disabled | getDownDisabledFace() |
face shown when button is down and disabled | down |
UiBinder
templates, you
can set text and assign ImageResources for their various faces via
child elements:
image
attribute
and an html body. For example:
<ui:image field='downButton'/> <!-- define an ImageResource
-->
<g:PushButton ui:field='pushButton' enabled='true'>
<g:upFace>
<b>click me</b>
</gwt:upFace>
<g:upHoveringFace>
<b>Click ME!</b>
</gwt:upHoveringFace>
<g:downFace image='{downButton}'/>
<g:downHoveringFace image='{downButton}'/>
</g:PushButton>
Modifier and Type | Class and Description |
---|---|
class |
CustomButton.Face
Represents a button's face.
|
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
DEBUG_ID_PREFIX
Modifier | Constructor and Description |
---|---|
protected |
CustomButton()
Constructor for
CustomButton . |
|
CustomButton(Image upImage)
Constructor for
CustomButton . |
|
CustomButton(Image upImage,
ClickHandler handler)
Constructor for
CustomButton . |
|
CustomButton(Image upImage,
ClickListener listener)
Deprecated.
Use
CustomButton(Image, ClickHandler) instead |
|
CustomButton(Image upImage,
Image downImage)
Constructor for
CustomButton . |
|
CustomButton(Image upImage,
Image downImage,
ClickHandler handler)
Constructor for
CustomButton . |
|
CustomButton(Image upImage,
Image downImage,
ClickListener listener)
Deprecated.
Use
CustomButton(Image, Image, ClickHandler) instead |
|
CustomButton(String upText)
Constructor for
CustomButton . |
|
CustomButton(String upText,
ClickHandler handler)
Constructor for
CustomButton . |
|
CustomButton(String upText,
ClickListener listener)
Deprecated.
Use
CustomButton(String, ClickListener) instead |
|
CustomButton(String upText,
String downText)
Constructor for
CustomButton . |
|
CustomButton(String upText,
String downText,
ClickHandler handler)
Constructor for
CustomButton . |
|
CustomButton(String upText,
String downText,
ClickListener listener)
Deprecated.
Use
CustomButton(String, String, ClickHandler) instead |
Modifier and Type | Method and Description |
---|---|
CustomButton.Face |
getDownDisabledFace()
Gets the downDisabled face of the button.
|
CustomButton.Face |
getDownFace()
Gets the down face of the button.
|
CustomButton.Face |
getDownHoveringFace()
Gets the downHovering face of the button.
|
String |
getHTML()
Gets the current face's html.
|
int |
getTabIndex()
Gets the tab index.
|
String |
getText()
Gets the current face's text.
|
CustomButton.Face |
getUpDisabledFace()
Gets the upDisabled face of the button.
|
CustomButton.Face |
getUpFace()
Gets the up face of the button.
|
CustomButton.Face |
getUpHoveringFace()
Gets the upHovering face of the button.
|
protected boolean |
isDown()
Is this button down?
|
protected void |
onAttach()
Overridden on attach to ensure that a button face has been chosen before
the button is displayed.
|
void |
onBrowserEvent(Event event)
Fired whenever a browser event is received.
|
protected void |
onClick()
Called when the user finishes clicking on this button.
|
protected void |
onClickCancel()
Called when the user aborts a click in progress; for example, by dragging
the mouse outside of the button before releasing the mouse button.
|
protected void |
onClickStart()
Called when the user begins to click on this button.
|
protected void |
onDetach()
This method is called when a widget is detached from the browser's
document.
|
void |
setAccessKey(char key)
Sets the widget's 'access key'.
|
protected void |
setDown(boolean down)
Sets whether this button is down.
|
void |
setEnabled(boolean enabled)
Sets whether this button is enabled.
|
void |
setFocus(boolean focused)
Explicitly focus/unfocus this widget.
|
void |
setHTML(SafeHtml html)
Sets this object's contents via known-safe HTML.
|
void |
setHTML(String html)
Sets the current face's html.
|
void |
setTabIndex(int index)
Sets the widget's position in the tab index.
|
void |
setText(String text)
Sets the current face's text.
|
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 CustomButton(Image upImage)
CustomButton
.upImage
- image for the default (up) face of the buttonpublic CustomButton(Image upImage, ClickHandler handler)
CustomButton
.upImage
- image for the default (up) face of the buttonhandler
- the click handler@Deprecated public CustomButton(Image upImage, ClickListener listener)
CustomButton(Image, ClickHandler)
insteadCustomButton
.upImage
- image for the default (up) face of the buttonlistener
- the click listenerpublic CustomButton(Image upImage, Image downImage)
CustomButton
.upImage
- image for the default (up) face of the buttondownImage
- image for the down face of the buttonpublic CustomButton(Image upImage, Image downImage, ClickHandler handler)
CustomButton
.upImage
- image for the default (up) face of the buttondownImage
- image for the down face of the buttonhandler
- clickListener@Deprecated public CustomButton(Image upImage, Image downImage, ClickListener listener)
CustomButton(Image, Image, ClickHandler)
insteadCustomButton
.upImage
- image for the default (up) face of the buttondownImage
- image for the down face of the buttonlistener
- clickListenerpublic CustomButton(String upText)
CustomButton
.upText
- the text for the default (up) face of the buttonpublic CustomButton(String upText, ClickHandler handler)
CustomButton
.upText
- the text for the default (up) face of the buttonhandler
- the click handler@Deprecated public CustomButton(String upText, ClickListener listener)
CustomButton(String, ClickListener)
insteadCustomButton
.upText
- the text for the default (up) face of the buttonlistener
- the click listenerpublic CustomButton(String upText, String downText)
CustomButton
.upText
- the text for the default (up) face of the buttondownText
- the text for the down face of the buttonpublic CustomButton(String upText, String downText, ClickHandler handler)
CustomButton
.upText
- the text for the default (up) face of the buttondownText
- the text for the down face of the buttonhandler
- the click handler@Deprecated public CustomButton(String upText, String downText, ClickListener listener)
CustomButton(String, String, ClickHandler)
insteadCustomButton
.upText
- the text for the default (up) face of the buttondownText
- the text for the down face of the buttonlistener
- the click listenerprotected CustomButton()
CustomButton
.public final CustomButton.Face getDownDisabledFace()
public final CustomButton.Face getDownFace()
public final CustomButton.Face getDownHoveringFace()
public String getHTML()
getHTML
in interface HasHTML
getHTML
in class ButtonBase
public int getTabIndex()
FocusWidget
getTabIndex
in interface Focusable
getTabIndex
in class FocusWidget
public String getText()
getText
in interface HasText
getText
in class ButtonBase
public final CustomButton.Face getUpDisabledFace()
public final CustomButton.Face getUpFace()
public final CustomButton.Face getUpHoveringFace()
public void onBrowserEvent(Event event)
EventListener
onBrowserEvent
in interface EventListener
onBrowserEvent
in class Widget
event
- the event receivedpublic void setAccessKey(char key)
Focusable
setAccessKey
in interface Focusable
setAccessKey
in class FocusWidget
key
- the widget's access keypublic final void setEnabled(boolean enabled)
setEnabled
in interface HasEnabled
setEnabled
in class FocusWidget
enabled
- true
to enable the button, false
to disable itpublic void setFocus(boolean focused)
Focusable
setFocus
in interface Focusable
setFocus
in class FocusWidget
focused
- whether this widget should take focus or release itpublic void setHTML(SafeHtml html)
HasSafeHtml
The object will behave exactly the same as when a widget's
HasHTML.setHTML(String)
method is
invoked; however the SafeHtml
passed to this method observes the
contract that it can be used in an HTML context without causing unsafe
script execution. Thus, unlike
HasHTML.setHTML(String)
, using this
method cannot result in Cross-Site Scripting security vulnerabilities.
setHTML
in interface HasSafeHtml
setHTML
in class ButtonBase
html
- the object's new HTML, represented as a SafeHtml
objectpublic void setHTML(String html)
setHTML
in interface HasHTML
setHTML
in class ButtonBase
html
- html to setpublic void setTabIndex(int index)
Focusable
-1
will cause this widget to
be removed from the tab order.setTabIndex
in interface Focusable
setTabIndex
in class FocusWidget
index
- the widget's tab indexpublic void setText(String text)
setText
in interface HasText
setText
in class ButtonBase
text
- text to setprotected boolean isDown()
true
if the button is downprotected void onAttach()
onAttach
in class FocusWidget
Widget.onLoad()
,
Widget.doAttachChildren()
protected void onClick()
onClickStart()
should override this method to restore the normal
widget display.protected void onClickCancel()
onClickStart()
should override this
method to restore the normal widget display.protected void onClickStart()
onClick()
and
onClickCancel()
to restore normal visual state. Each
onClickStart
will eventually be followed by either
onClick
or onClickCancel
, depending on whether
the click is completed.protected void onDetach()
Widget
This method is called when a widget is detached from the browser's
document. To receive notification before a Widget is removed from the
document, override the Widget.onUnload()
method or use Widget.addAttachHandler(com.google.gwt.event.logical.shared.AttachEvent.Handler)
.
It is strongly recommended that you override Widget.onUnload()
or
Widget.doDetachChildren()
instead of this method to avoid inconsistencies
between logical and physical attachment states.
Subclasses that override this method must call
super.onDetach()
to ensure that the Widget has been detached
from the underlying Element. Failure to do so will result in application
memory leaks due to circular references between DOM Elements and JavaScript
objects.
onDetach
in class Widget
Widget.onUnload()
,
Widget.doDetachChildren()
protected void setDown(boolean down)
down
- true
to press the button, false
otherwiseCopyright © 2018. All rights reserved.