Class Button

All Implemented Interfaces:
HasAttachHandlers, HasHandlers, EventListener, HasVisibility, IsWidget, LogicalStructure, HasClearHandlers, HasClickHandlers, HasDoubleClickHandlers, HasDragMoveHandlers, HasDragRepositionMoveHandlers, HasDragRepositionStartHandlers, HasDragRepositionStopHandlers, HasDragResizeMoveHandlers, HasDragResizeStartHandlers, HasDragResizeStopHandlers, HasDragStartHandlers, HasDragStopHandlers, HasDropHandlers, HasDropMoveHandlers, HasDropOutHandlers, HasDropOverHandlers, HasFocusChangedHandlers, HasHoverHandlers, HasHoverHiddenHandlers, HasIconClickHandlers, HasKeyDownHandlers, HasKeyPressHandlers, HasMouseDownHandlers, HasMouseMoveHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasMouseStillDownHandlers, HasMouseUpHandlers, HasMouseWheelHandlers, HasMovedHandlers, HasParentMovedHandlers, HasResizedHandlers, HasRightMouseDownHandlers, HasRuleContextChangedHandlers, HasScrolledHandlers, HasShowContextMenuHandlers, HasTitleHoverHandlers, HasVisibilityChangedHandlers
Direct Known Subclasses:
Label, MenuButton, NavigationButton, RibbonButton, ToolStripButton

public class Button extends StatefulCanvas implements HasIconClickHandlers, HasTitleHoverHandlers
The Button widget class implements interactive, style-based button widgets.
  • Constructor Details

  • Method Details

    • getOrCreateRef

      public static Button getOrCreateRef(JavaScriptObject jsObj)
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, Canvas defaults)
      Changes the defaults for Canvas AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - Canvas defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, FormItem defaults)
      Changes the defaults for FormItem AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - FormItem defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • create

      protected JavaScriptObject create()
      Overrides:
      create in class StatefulCanvas
    • setActionType

      public Button setActionType(SelectionType actionType)
      Behavior on state changes -- BUTTON, RADIO or CHECKBOX

      If this method is called after the component has been drawn/initialized: Update the 'actionType' for this canvas (radio / checkbox / button) If the canvas is currently selected, and the passed in actionType is 'button' this method will deselect the canvas.
      Overrides:
      setActionType in class StatefulCanvas
      Parameters:
      actionType - new action type. Default value is "button"
      Returns:
      Button instance, for chaining setter calls
      See Also:
    • getActionType

      public SelectionType getActionType()
      Behavior on state changes -- BUTTON, RADIO or CHECKBOX
      Overrides:
      getActionType in class StatefulCanvas
      Returns:
      Return the 'actionType' for this canvas (radio / checkbox / button). Default value is "button"
      See Also:
    • setAdaptWidthShowIconOnly

      public Button setAdaptWidthShowIconOnly(boolean adaptWidthShowIconOnly)
      If canAdaptWidth is true, and this button has a specified icon, should the title be hidden, allowing the button to shrink down to just show the icon when there isn't enough horizontal space in a layout to show the default sized button?
      Parameters:
      adaptWidthShowIconOnly - New adaptWidthShowIconOnly value. Default value is true
      Returns:
      Button instance, for chaining setter calls
      See Also:
    • getAdaptWidthShowIconOnly

      public boolean getAdaptWidthShowIconOnly()
      If canAdaptWidth is true, and this button has a specified icon, should the title be hidden, allowing the button to shrink down to just show the icon when there isn't enough horizontal space in a layout to show the default sized button?
      Returns:
      Current adaptWidthShowIconOnly value. Default value is true
      See Also:
    • setAlign

      public Button setAlign(Alignment align)
      Horizontal alignment of this component's title.

      If this method is called after the component has been drawn/initialized: Sets the (horizontal) alignment of this buttons content.
      Overrides:
      setAlign in class StatefulCanvas
      Parameters:
      align - New align value. Default value is Canvas.CENTER
      Returns:
      Button instance, for chaining setter calls
      See Also:
    • getAlign

      public Alignment getAlign()
      Horizontal alignment of this component's title.
      Overrides:
      getAlign in class StatefulCanvas
      Returns:
      Current align value. Default value is Canvas.CENTER
      See Also:
    • setAutoFit

      public Button setAutoFit(Boolean autoFit)
      If true, ignore the specified size of this widget and always size just large enough to accommodate the title. If setWidth() is explicitly called on an autoFit:true button, autoFit will be reset to false.

      Note that for StretchImgButton instances, autoFit will occur horizontally only, as unpredictable vertical sizing is likely to distort the media. If you do want vertical auto-fit, this can be achieved by simply setting a small height, and having overflow:"visible"

      If this method is called after the component has been drawn/initialized: Setter method for the StatefulCanvas.autoFit property. Pass in true or false to turn autoFit on or off. When autoFit is set to false, canvas will be resized to it's previously specified size.

      Overrides:
      setAutoFit in class StatefulCanvas
      Parameters:
      autoFit - New autoFit setting. Default value is null
      Returns:
      Button instance, for chaining setter calls
      See Also:
    • getAutoFit

      public Boolean getAutoFit()
      If true, ignore the specified size of this widget and always size just large enough to accommodate the title. If setWidth() is explicitly called on an autoFit:true button, autoFit will be reset to false.

      Note that for StretchImgButton instances, autoFit will occur horizontally only, as unpredictable vertical sizing is likely to distort the media. If you do want vertical auto-fit, this can be achieved by simply setting a small height, and having overflow:"visible"

      Overrides:
      getAutoFit in class StatefulCanvas
      Returns:
      Current autoFit value. Default value is null
      See Also:
    • setBaseStyle

      public Button setBaseStyle(String baseStyle)
      Base CSS style className applied to the component.

      Note that if specified, this property takes precedence over any specified StatefulCanvas.styleName. If unset, the styleName will be used as a default baseStyle value.

      As the component changes StatefulCanvas.state and/or is selected, suffixes will be added to the base style. In some cases more than one suffix will be appended to reflect a combined state ("Selected" + "Disabled", for example).

      See StatefulCanvas.getStateSuffix() for a description of the default set of suffixes which may be applied to the baseStyle

      Rotated Titles

      The Framework doesn't have built-in support for rotating button titles in a fashion similar to FacetChart.rotateLabels. However, you can manually configure a button to render with a rotated title by applying custom CSS via this property.

      For example, given a button with a height of 120 and a width of 48, if you copied the existing buttonXXX style declarations from skin_styles.css as new, rotatedTitleButtonXXX declarations, and then added the lines:

            -ms-transform:     translate(-38px,0px) rotate(270deg);
            -webkit-transform: translate(-38px,0px) rotate(270deg);
            transform:         translate(-38px,0px) rotate(270deg);
            overflow: hidden;
            text-overflow: ellipsis;
            width:116px;
      in the declaration section beginning:
        .rotatedTitleButton,
        .rotatedTitleButtonSelected,
        .rotatedTitleButtonSelectedOver,
        .rotatedTitleButtonSelectedDown,
        .rotatedTitleButtonSelectedDisabled,
        .rotatedTitleButtonOver,
        .rotatedTitleButtonDown,
        .rotatedTitleButtonDisabled {
      then applying that style to the button with overflow: "clip_h" would yield a vertically-rendered title with overflow via ellipsis as expected, and also wrap with wrap. Note that:
      • The explicit width applied via CSS is needed because rotated elements don't inherit dimensions in their new orientation from the DOM - the transform/rotation occurs independently of layout.
      • The translation transform required along the x-axis is roughly (width - height) / 2, but may need slight offsetting for optimal centering.
      • We've explicitly avoided describing an approach based on CSS "writing-mode", since support is incomplete and bugs are present in popular browsers such as Firefox and Safari that would prevent it from being used without Framework assistance.

      Note on css-margins: Developers should be aware that the css "margin" property is unreliable for certain subclasses of StatefulCanvas, including buttons. Developers may use the explicit Canvas.margin property to specify button margins, or for a button within a layout, consider the layout properties Layout.layoutMargin, Layout.membersMargin

      If this method is called after the component has been drawn/initialized: Sets the base CSS style. As the component changes state and/or is selected, suffixes will be added to the base style.

      Overrides:
      setBaseStyle in class StatefulCanvas
      Parameters:
      baseStyle - new base style. Default value is "button"
      Returns:
      Button instance, for chaining setter calls
      See Also:
    • getBaseStyle

      public String getBaseStyle()
      Base CSS style className applied to the component.

      Note that if specified, this property takes precedence over any specified StatefulCanvas.styleName. If unset, the styleName will be used as a default baseStyle value.

      As the component changes StatefulCanvas.state and/or is selected, suffixes will be added to the base style. In some cases more than one suffix will be appended to reflect a combined state ("Selected" + "Disabled", for example).

      See StatefulCanvas.getStateSuffix() for a description of the default set of suffixes which may be applied to the baseStyle

      Rotated Titles

      The Framework doesn't have built-in support for rotating button titles in a fashion similar to FacetChart.rotateLabels. However, you can manually configure a button to render with a rotated title by applying custom CSS via this property.

      For example, given a button with a height of 120 and a width of 48, if you copied the existing buttonXXX style declarations from skin_styles.css as new, rotatedTitleButtonXXX declarations, and then added the lines:

            -ms-transform:     translate(-38px,0px) rotate(270deg);
            -webkit-transform: translate(-38px,0px) rotate(270deg);
            transform:         translate(-38px,0px) rotate(270deg);
            overflow: hidden;
            text-overflow: ellipsis;
            width:116px;
      in the declaration section beginning:
        .rotatedTitleButton,
        .rotatedTitleButtonSelected,
        .rotatedTitleButtonSelectedOver,
        .rotatedTitleButtonSelectedDown,
        .rotatedTitleButtonSelectedDisabled,
        .rotatedTitleButtonOver,
        .rotatedTitleButtonDown,
        .rotatedTitleButtonDisabled {
      then applying that style to the button with overflow: "clip_h" would yield a vertically-rendered title with overflow via ellipsis as expected, and also wrap with wrap. Note that:
      • The explicit width applied via CSS is needed because rotated elements don't inherit dimensions in their new orientation from the DOM - the transform/rotation occurs independently of layout.
      • The translation transform required along the x-axis is roughly (width - height) / 2, but may need slight offsetting for optimal centering.
      • We've explicitly avoided describing an approach based on CSS "writing-mode", since support is incomplete and bugs are present in popular browsers such as Firefox and Safari that would prevent it from being used without Framework assistance.

      Note on css-margins: Developers should be aware that the css "margin" property is unreliable for certain subclasses of StatefulCanvas, including buttons. Developers may use the explicit Canvas.margin property to specify button margins, or for a button within a layout, consider the layout properties Layout.layoutMargin, Layout.membersMargin

      Overrides:
      getBaseStyle in class StatefulCanvas
      Returns:
      Current baseStyle value. Default value is "button"
      See Also:
    • setCanAdaptWidth

      public Button setCanAdaptWidth(Boolean canAdaptWidth) throws IllegalStateException
      This flag enables adaptive width for the button.

      If enabled the button will support rendering in a 'collapsed' view if there isn't enough space in a layout to render it at normal size. There are a couple of ways this can be achieved.

      • If adaptWidthShowIconOnly is true and this button shows an icon, the title will be hidden if there isn't enough space to render it, allowing it to shrink to either the rendered icon width, or any specified minWidth, whichever is larger.
      • Otherwise, if the button has a specified minWidth, and autoFit is true, autoFit will be temporarily disabled, if there isn't enough room, allowing the title to be clipped
      In either case the title will show on hover unless an explicit hover has been specified such as by overriding titleHoverHTML().
      Overrides:
      setCanAdaptWidth in class Canvas
      Parameters:
      canAdaptWidth - New canAdaptWidth value. Default value is false
      Returns:
      Button instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getCanAdaptWidth

      public Boolean getCanAdaptWidth()
      This flag enables adaptive width for the button.

      If enabled the button will support rendering in a 'collapsed' view if there isn't enough space in a layout to render it at normal size. There are a couple of ways this can be achieved.

      • If adaptWidthShowIconOnly is true and this button shows an icon, the title will be hidden if there isn't enough space to render it, allowing it to shrink to either the rendered icon width, or any specified minWidth, whichever is larger.
      • Otherwise, if the button has a specified minWidth, and autoFit is true, autoFit will be temporarily disabled, if there isn't enough room, allowing the title to be clipped
      In either case the title will show on hover unless an explicit hover has been specified such as by overriding titleHoverHTML().
      Overrides:
      getCanAdaptWidth in class Canvas
      Returns:
      Current canAdaptWidth value. Default value is false
      See Also:
    • setDefiningProperty

      public Button setDefiningProperty(String definingProperty)
      This attribute denotes the name of a property to use as a getDefiningPropertyName() for this property when generating and resolving AutoTest locators with search segments.

      Note : This is an advanced setting

      Overrides:
      setDefiningProperty in class Canvas
      Parameters:
      definingProperty - New definingProperty value. Default value is "title"
      Returns:
      Button instance, for chaining setter calls
    • getDefiningProperty

      public String getDefiningProperty()
      This attribute denotes the name of a property to use as a getDefiningPropertyName() for this property when generating and resolving AutoTest locators with search segments.
      Overrides:
      getDefiningProperty in class Canvas
      Returns:
      Current definingProperty value. Default value is "title"
    • setDisabledIconCursor

      public Button setDisabledIconCursor(Cursor disabledIconCursor) throws IllegalStateException
      Specifies the cursor to display when the mouse pointer is over the icon image and this StatefulCanvas is disabled.

      If not set and the mouse pointer is over the icon image, iconCursor will be used.

      Parameters:
      disabledIconCursor - New disabledIconCursor value. Default value is null
      Returns:
      Button instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getDisabledIconCursor

      public Cursor getDisabledIconCursor()
      Specifies the cursor to display when the mouse pointer is over the icon image and this StatefulCanvas is disabled.

      If not set and the mouse pointer is over the icon image, iconCursor will be used.

      Returns:
      Current disabledIconCursor value. Default value is null
      See Also:
    • setHeight

      public Button setHeight(Integer height)
      Size for this component's vertical dimension. See Canvas.height for more details.

      Note that if StatefulCanvas.autoFit is set on non-StretchImgButton instances, this property will be ignored so that the widget is always sized just large enough to accommodate the title.

      Overrides:
      setHeight in class StatefulCanvas
      Parameters:
      height - New height value. Default value is null
      Returns:
      Button instance, for chaining setter calls
      See Also:
    • getHeight

      public Integer getHeight()
      Size for this component's vertical dimension. See Canvas.height for more details.

      Note that if StatefulCanvas.autoFit is set on non-StretchImgButton instances, this property will be ignored so that the widget is always sized just large enough to accommodate the title.

      Overrides:
      getHeight in class StatefulCanvas
      Returns:
      Current height value. Default value is null
      See Also:
    • setHeight

      public void setHeight(String height)
      Size for this component's vertical dimension. See Canvas.height for more details.

      Note that if StatefulCanvas.autoFit is set on non-StretchImgButton instances, this property will be ignored so that the widget is always sized just large enough to accommodate the title.

      Overrides:
      setHeight in class StatefulCanvas
      Parameters:
      height - New height value. Default value is null
      See Also:
    • getHeightAsString

      public String getHeightAsString()
      Size for this component's vertical dimension. See Canvas.height for more details.

      Note that if StatefulCanvas.autoFit is set on non-StretchImgButton instances, this property will be ignored so that the widget is always sized just large enough to accommodate the title.

      Overrides:
      getHeightAsString in class StatefulCanvas
      Returns:
      Current height value. Default value is null
      See Also:
    • setHiliteAccessKey

      public Button setHiliteAccessKey(Boolean hiliteAccessKey)
      If set to true, if the title of this button contains the specified accessKey, when the title is displayed to the user it will be modified to include HTML to underline the accessKey.
      Note that this property may cause titles that include HTML (rather than simple strings) to be inappropriately modified, so should be disabled if your title string includes HTML characters.
      Parameters:
      hiliteAccessKey - New hiliteAccessKey value. Default value is null
      Returns:
      Button instance, for chaining setter calls
    • getHiliteAccessKey

      public Boolean getHiliteAccessKey()
      If set to true, if the title of this button contains the specified accessKey, when the title is displayed to the user it will be modified to include HTML to underline the accessKey.
      Note that this property may cause titles that include HTML (rather than simple strings) to be inappropriately modified, so should be disabled if your title string includes HTML characters.
      Returns:
      Current hiliteAccessKey value. Default value is null
    • setIcon

      public Button setIcon(String icon)
      Optional icon to be shown with the button title text.

      Specify as the partial URL to an image, relative to the imgDir of this component. A sprited image can be specified using the SCSpriteConfig format.

      Note that the string "blank" is a valid setting for this attribute and will always result in the system blank image, with no state suffixes applied. Typically, this might be used when an iconStyle is also specified and the iconStyle renders the icon via a stateful background-image or other CSS approach.

      If this method is called after the component has been drawn/initialized: Change the icon being shown next to the title text.

      Overrides:
      setIcon in class StatefulCanvas
      Parameters:
      icon - URL of new icon. Default value is null
      Returns:
      Button instance, for chaining setter calls
      See Also:
    • getIcon

      public String getIcon()
      Optional icon to be shown with the button title text.

      Specify as the partial URL to an image, relative to the imgDir of this component. A sprited image can be specified using the SCSpriteConfig format.

      Note that the string "blank" is a valid setting for this attribute and will always result in the system blank image, with no state suffixes applied. Typically, this might be used when an iconStyle is also specified and the iconStyle renders the icon via a stateful background-image or other CSS approach.

      Overrides:
      getIcon in class StatefulCanvas
      Returns:
      Current icon value. Default value is null
      See Also:
    • setIconAlign

      public Button setIconAlign(String iconAlign) throws IllegalStateException
      If this button is showing an icon should it be right or left aligned?
      Parameters:
      iconAlign - New iconAlign value. Default value is null
      Returns:
      Button instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getIconAlign

      public String getIconAlign()
      If this button is showing an icon should it be right or left aligned?
      Returns:
      Current iconAlign value. Default value is null
      See Also:
    • setIconCursor

      public Button setIconCursor(Cursor iconCursor) throws IllegalStateException
      Specifies the cursor to display when the mouse pointer is over the icon image.
      Parameters:
      iconCursor - New iconCursor value. Default value is null
      Returns:
      Button instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getIconCursor

      public Cursor getIconCursor()
      Specifies the cursor to display when the mouse pointer is over the icon image.
      Returns:
      Current iconCursor value. Default value is null
      See Also:
    • setIconHeight

      public Button setIconHeight(Integer iconHeight) throws IllegalStateException
      Height in pixels of the icon image.

      If unset, defaults to iconSize.

      Overrides:
      setIconHeight in class StatefulCanvas
      Parameters:
      iconHeight - New iconHeight value. Default value is null
      Returns:
      Button instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getIconHeight

      public Integer getIconHeight()
      Height in pixels of the icon image.

      If unset, defaults to iconSize.

      Overrides:
      getIconHeight in class StatefulCanvas
      Returns:
      Current iconHeight value. Default value is null
      See Also:
    • setIconOnlyBaseStyle

      public Button setIconOnlyBaseStyle(String iconOnlyBaseStyle)
      if defined, iconOnlyBaseStyle is used as the base CSS style className, instead of baseStyle, if canAdaptWidth is set and the title is not being shown.
      Parameters:
      iconOnlyBaseStyle - New iconOnlyBaseStyle value. Default value is null
      Returns:
      Button instance, for chaining setter calls
      See Also:
    • getIconOnlyBaseStyle

      public String getIconOnlyBaseStyle()
      if defined, iconOnlyBaseStyle is used as the base CSS style className, instead of baseStyle, if canAdaptWidth is set and the title is not being shown.
      Returns:
      Current iconOnlyBaseStyle value. Default value is null
      See Also:
    • setIconOrientation

      public Button setIconOrientation(String iconOrientation) throws IllegalStateException
      If this button is showing an icon should it appear to the left or right of the title? valid options are "left" and "right".

      If this method is called after the component has been drawn/initialized: Changes the orientation of the icon relative to the text of the button.
      Overrides:
      setIconOrientation in class StatefulCanvas
      Parameters:
      iconOrientation - The new orientation of the icon relative to the text of the button. Default value is "left"
      Returns:
      Button instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getIconOrientation

      public String getIconOrientation()
      If this button is showing an icon should it appear to the left or right of the title? valid options are "left" and "right".
      Overrides:
      getIconOrientation in class StatefulCanvas
      Returns:
      Current iconOrientation value. Default value is "left"
      See Also:
    • setIconSize

      public Button setIconSize(int iconSize) throws IllegalStateException
      Size in pixels of the icon image.

      The iconWidth and iconHeight properties can be used to configure width and height separately.

      Note: When configuring the properties of a StatefulCanvas (or derivative) AutoChild, it is best to set the iconWidth and iconHeight to the same value rather than setting an iconSize. This is because certain skins or customizations thereto might set the iconWidth and iconHeight, making the customization of the AutoChild's iconSize ineffective.

      Overrides:
      setIconSize in class StatefulCanvas
      Parameters:
      iconSize - New iconSize value. Default value is 16
      Returns:
      Button instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getIconSize

      public int getIconSize()
      Size in pixels of the icon image.

      The iconWidth and iconHeight properties can be used to configure width and height separately.

      Note: When configuring the properties of a StatefulCanvas (or derivative) AutoChild, it is best to set the iconWidth and iconHeight to the same value rather than setting an iconSize. This is because certain skins or customizations thereto might set the iconWidth and iconHeight, making the customization of the AutoChild's iconSize ineffective.

      Overrides:
      getIconSize in class StatefulCanvas
      Returns:
      Current iconSize value. Default value is 16
      See Also:
    • setIconSpacing

      public Button setIconSpacing(int iconSpacing) throws IllegalStateException
      Pixels between icon and title text.
      Parameters:
      iconSpacing - New iconSpacing value. Default value is 6
      Returns:
      Button instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getIconSpacing

      public int getIconSpacing()
      Pixels between icon and title text.
      Returns:
      Current iconSpacing value. Default value is 6
      See Also:
    • setIconStyle

      public Button setIconStyle(String iconStyle)
      Base CSS style applied to the icon image. If set, as the StatefulCanvas changes state and/or is selected, suffixes will be appended to iconStyle to form the className set on the image element.

      The following table lists out the standard set of suffixes which may be appended:

      CSS Class AppliedDescription
      iconStyleDefault CSS style
      iconStyle+Selected Applied when StatefulCanvas.selected and StatefulCanvas.showSelectedIcon are true.
      iconStyle+Focused Applied when the component has keyboard focus, if StatefulCanvas.showFocusedIcon is true, and StatefulCanvas.showFocusedAsOver is not true.
      iconStyle+Over Applied when StatefulCanvas.showRollOverIcon is set to true and either the user rolls over the component or StatefulCanvas.showFocusedAsOver is true and the component has keyboard focus.
      iconStyle+Down Applied when the user presses the mouse button on the component if StatefulCanvas.showDownIcon is set to true
      iconStyle+Disabled Applied when the component is disabled if StatefulCanvas.showDisabledIcon is true.
      Combined styles
      iconStyle+SelectedFocused Combined Selected and focused styling
      iconStyle+SelectedOver Combined Selected and rollOver styling
      iconStyle+FocusedOver Combined Focused and rollOver styling
      iconStyle+SelectedFocusedOver Combined Selected, Focused and rollOver styling
      iconStyle+SelectedDown Combined Selected and mouse-down styling
      iconStyle+FocusedDown Combined Focused and mouse-down styling
      iconStyle+SelectedFocusedDown Combined Selected, Focused and mouse-down styling
      iconStyle+SelectedDisabled Combined Selected and Disabled styling

      In addition, if StatefulCanvas.showRTLIcon is true, then in RTL mode, a final "RTL" suffix will be appended.

      Overrides:
      setIconStyle in class StatefulCanvas
      Parameters:
      iconStyle - New iconStyle value. Default value is null
      Returns:
      Button instance, for chaining setter calls
      See Also:
    • getIconStyle

      public String getIconStyle()
      Base CSS style applied to the icon image. If set, as the StatefulCanvas changes state and/or is selected, suffixes will be appended to iconStyle to form the className set on the image element.

      The following table lists out the standard set of suffixes which may be appended:

      CSS Class AppliedDescription
      iconStyleDefault CSS style
      iconStyle+Selected Applied when StatefulCanvas.selected and StatefulCanvas.showSelectedIcon are true.
      iconStyle+Focused Applied when the component has keyboard focus, if StatefulCanvas.showFocusedIcon is true, and StatefulCanvas.showFocusedAsOver is not true.
      iconStyle+Over Applied when StatefulCanvas.showRollOverIcon is set to true and either the user rolls over the component or StatefulCanvas.showFocusedAsOver is true and the component has keyboard focus.
      iconStyle+Down Applied when the user presses the mouse button on the component if StatefulCanvas.showDownIcon is set to true
      iconStyle+Disabled Applied when the component is disabled if StatefulCanvas.showDisabledIcon is true.
      Combined styles
      iconStyle+SelectedFocused Combined Selected and focused styling
      iconStyle+SelectedOver Combined Selected and rollOver styling
      iconStyle+FocusedOver Combined Focused and rollOver styling
      iconStyle+SelectedFocusedOver Combined Selected, Focused and rollOver styling
      iconStyle+SelectedDown Combined Selected and mouse-down styling
      iconStyle+FocusedDown Combined Focused and mouse-down styling
      iconStyle+SelectedFocusedDown Combined Selected, Focused and mouse-down styling
      iconStyle+SelectedDisabled Combined Selected and Disabled styling

      In addition, if StatefulCanvas.showRTLIcon is true, then in RTL mode, a final "RTL" suffix will be appended.

      Overrides:
      getIconStyle in class StatefulCanvas
      Returns:
      Current iconStyle value. Default value is null
      See Also:
    • setIconWidth

      public Button setIconWidth(Integer iconWidth) throws IllegalStateException
      Width in pixels of the icon image.

      If unset, defaults to iconSize.

      Overrides:
      setIconWidth in class StatefulCanvas
      Parameters:
      iconWidth - New iconWidth value. Default value is null
      Returns:
      Button instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getIconWidth

      public Integer getIconWidth()
      Width in pixels of the icon image.

      If unset, defaults to iconSize.

      Overrides:
      getIconWidth in class StatefulCanvas
      Returns:
      Current iconWidth value. Default value is null
      See Also:
    • setOverflow

      public Button setOverflow(Overflow overflow)
      Clip the contents of the button if necessary.

      Note : This is an advanced setting

      Overrides:
      setOverflow in class Canvas
      Parameters:
      overflow - New overflow value. Default value is Canvas.HIDDEN
      Returns:
      Button instance, for chaining setter calls
      See Also:
    • getOverflow

      public Overflow getOverflow()
      Clip the contents of the button if necessary.
      Overrides:
      getOverflow in class Canvas
      Returns:
      Current overflow value. Default value is Canvas.HIDDEN
      See Also:
    • setRadioGroup

      public Button setRadioGroup(String radioGroup)
      String identifier for this canvas's mutually exclusive selection group.

      Note : This is an advanced setting

      Overrides:
      setRadioGroup in class StatefulCanvas
      Parameters:
      radioGroup - New radioGroup value. Default value is null
      Returns:
      Button instance, for chaining setter calls
      See Also:
    • getRadioGroup

      public String getRadioGroup()
      String identifier for this canvas's mutually exclusive selection group.
      Overrides:
      getRadioGroup in class StatefulCanvas
      Returns:
      Current radioGroup value. Default value is null
      See Also:
    • setShowClippedTitleOnHover

      public Button setShowClippedTitleOnHover(Boolean showClippedTitleOnHover)
      If true and the title is clipped, then a hover containing the full title of this button is enabled.
      Parameters:
      showClippedTitleOnHover - New showClippedTitleOnHover value. Default value is false
      Returns:
      Button instance, for chaining setter calls
    • getShowClippedTitleOnHover

      public Boolean getShowClippedTitleOnHover()
      If true and the title is clipped, then a hover containing the full title of this button is enabled.
      Returns:
      Current showClippedTitleOnHover value. Default value is false
    • setShowDisabled

      public Button setShowDisabled(Boolean showDisabled)
      Should we visibly change state when disabled?
      Overrides:
      setShowDisabled in class StatefulCanvas
      Parameters:
      showDisabled - New showDisabled value. Default value is true
      Returns:
      Button instance, for chaining setter calls
      See Also:
    • getShowDisabled

      public Boolean getShowDisabled()
      Should we visibly change state when disabled?
      Overrides:
      getShowDisabled in class StatefulCanvas
      Returns:
      Current showDisabled value. Default value is true
      See Also:
    • setShowDisabledIcon

      public Button setShowDisabledIcon(Boolean showDisabledIcon) throws IllegalStateException
      If using an icon for this button, whether to switch the icon image if the button becomes disabled.
      Overrides:
      setShowDisabledIcon in class StatefulCanvas
      Parameters:
      showDisabledIcon - New showDisabledIcon value. Default value is true
      Returns:
      Button instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getShowDisabledIcon

      public Boolean getShowDisabledIcon()
      If using an icon for this button, whether to switch the icon image if the button becomes disabled.
      Overrides:
      getShowDisabledIcon in class StatefulCanvas
      Returns:
      Current showDisabledIcon value. Default value is true
      See Also:
    • setShowDown

      public Button setShowDown(Boolean showDown)
      Should we visibly change state when the mouse goes down in this object?
      Overrides:
      setShowDown in class StatefulCanvas
      Parameters:
      showDown - New showDown value. Default value is false
      Returns:
      Button instance, for chaining setter calls
      See Also:
    • getShowDown

      public Boolean getShowDown()
      Should we visibly change state when the mouse goes down in this object?
      Overrides:
      getShowDown in class StatefulCanvas
      Returns:
      Current showDown value. Default value is false
      See Also:
    • setShowDownIcon

      public Button setShowDownIcon(Boolean showDownIcon) throws IllegalStateException
      If using an icon for this button, whether to switch the icon image when the mouse goes down on the button.
      Overrides:
      setShowDownIcon in class StatefulCanvas
      Parameters:
      showDownIcon - New showDownIcon value. Default value is false
      Returns:
      Button instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getShowDownIcon

      public Boolean getShowDownIcon()
      If using an icon for this button, whether to switch the icon image when the mouse goes down on the button.
      Overrides:
      getShowDownIcon in class StatefulCanvas
      Returns:
      Current showDownIcon value. Default value is false
      See Also:
    • setShowFocused

      public Button setShowFocused(Boolean showFocused)
      Should we visibly change state when the canvas receives focus? If StatefulCanvas.showFocusedAsOver is true, then "over" will be used to indicate focus. Otherwise a separate "focused" state will be used.
      Overrides:
      setShowFocused in class StatefulCanvas
      Parameters:
      showFocused - New showFocused value. Default value is false
      Returns:
      Button instance, for chaining setter calls
      See Also:
    • getShowFocused

      public Boolean getShowFocused()
      Should we visibly change state when the canvas receives focus? If StatefulCanvas.showFocusedAsOver is true, then "over" will be used to indicate focus. Otherwise a separate "focused" state will be used.
      Overrides:
      getShowFocused in class StatefulCanvas
      Returns:
      Current showFocused value. Default value is false
      See Also:
    • setShowFocusedIcon

      public Button setShowFocusedIcon(Boolean showFocusedIcon) throws IllegalStateException
      If using an icon for this button, whether to switch the icon image when the button receives focus.

      If StatefulCanvas.showFocusedAsOver is true, the "Over" icon will be displayed when the canvas has focus, otherwise a separate "Focused" icon will be displayed

      Overrides:
      setShowFocusedIcon in class StatefulCanvas
      Parameters:
      showFocusedIcon - New showFocusedIcon value. Default value is false
      Returns:
      Button instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getShowFocusedIcon

      public Boolean getShowFocusedIcon()
      If using an icon for this button, whether to switch the icon image when the button receives focus.

      If StatefulCanvas.showFocusedAsOver is true, the "Over" icon will be displayed when the canvas has focus, otherwise a separate "Focused" icon will be displayed

      Overrides:
      getShowFocusedIcon in class StatefulCanvas
      Returns:
      Current showFocusedIcon value. Default value is false
      See Also:
    • setShowRollOver

      public Button setShowRollOver(Boolean showRollOver)
      Should we visibly change state when the mouse goes over this object?
      Overrides:
      setShowRollOver in class StatefulCanvas
      Parameters:
      showRollOver - New showRollOver value. Default value is false
      Returns:
      Button instance, for chaining setter calls
      See Also:
    • getShowRollOver

      public Boolean getShowRollOver()
      Should we visibly change state when the mouse goes over this object?
      Overrides:
      getShowRollOver in class StatefulCanvas
      Returns:
      Current showRollOver value. Default value is false
      See Also:
    • setShowRollOverIcon

      public Button setShowRollOverIcon(Boolean showRollOverIcon) throws IllegalStateException
      If using an icon for this button, whether to switch the icon image on mouse rollover.
      Overrides:
      setShowRollOverIcon in class StatefulCanvas
      Parameters:
      showRollOverIcon - New showRollOverIcon value. Default value is false
      Returns:
      Button instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getShowRollOverIcon

      public Boolean getShowRollOverIcon()
      If using an icon for this button, whether to switch the icon image on mouse rollover.
      Overrides:
      getShowRollOverIcon in class StatefulCanvas
      Returns:
      Current showRollOverIcon value. Default value is false
      See Also:
    • setShowSelectedIcon

      public Button setShowSelectedIcon(Boolean showSelectedIcon) throws IllegalStateException
      If using an icon for this button, whether to switch the icon image when the button becomes selected.
      Overrides:
      setShowSelectedIcon in class StatefulCanvas
      Parameters:
      showSelectedIcon - New showSelectedIcon value. Default value is false
      Returns:
      Button instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getShowSelectedIcon

      public Boolean getShowSelectedIcon()
      If using an icon for this button, whether to switch the icon image when the button becomes selected.
      Overrides:
      getShowSelectedIcon in class StatefulCanvas
      Returns:
      Current showSelectedIcon value. Default value is false
      See Also:
    • setState

      public Button setState(State state)
      Current "state" of this widget. The state setting is automatically updated as the user interacts with the component (see StatefulCanvas.showRollOver, StatefulCanvas.showDown, StatefulCanvas.showDisabled).

      StatefulCanvases will have a different appearance based on their current state. By default this is handled by changing the css className applied to the StatefulCanvas - see StatefulCanvas.baseStyle and StatefulCanvas.getStateSuffix() for a description of how this is done.

      For Img or StretchImg based subclasses of StatefulCanvas, the appearance may also be updated by changing the src of the rendered image. See Img.src and StretchImgButton.src for a description of how the URL is modified to reflect the state of the widget in this case.

      If this method is called after the component has been drawn/initialized: Sets the state of this object, changing its appearance. Note: newState cannot be State.STATE_DISABLED if this.showDisabled is false.

      Note : This is an advanced setting

      Overrides:
      setState in class StatefulCanvas
      Parameters:
      state - the new state. Default value is ""
      Returns:
      Button instance, for chaining setter calls
      See Also:
    • getState

      public State getState()
      Current "state" of this widget. The state setting is automatically updated as the user interacts with the component (see StatefulCanvas.showRollOver, StatefulCanvas.showDown, StatefulCanvas.showDisabled).

      StatefulCanvases will have a different appearance based on their current state. By default this is handled by changing the css className applied to the StatefulCanvas - see StatefulCanvas.baseStyle and StatefulCanvas.getStateSuffix() for a description of how this is done.

      For Img or StretchImg based subclasses of StatefulCanvas, the appearance may also be updated by changing the src of the rendered image. See Img.src and StretchImgButton.src for a description of how the URL is modified to reflect the state of the widget in this case.

      Overrides:
      getState in class StatefulCanvas
      Returns:
      Return the state of this StatefulCanvas. Default value is ""
      See Also:
    • setStyleName

      public void setStyleName(String styleName)
      StatefulCanvases are styled by combining baseStyle with State to build a composite css style name. In most cases, statefulCanvas.styleName will have no effect on statefulCanvas styling and should not be used.

      If the baseStyle is not explicitly specified for a class, the styleName will be used as a default baseStyle. Other than that, this attribute will be ignored.

      Overrides:
      setStyleName in class StatefulCanvas
      Parameters:
      styleName - New styleName value. Default value is "normal"
      See Also:
    • getStyleName

      public String getStyleName()
      StatefulCanvases are styled by combining baseStyle with State to build a composite css style name. In most cases, statefulCanvas.styleName will have no effect on statefulCanvas styling and should not be used.

      If the baseStyle is not explicitly specified for a class, the styleName will be used as a default baseStyle. Other than that, this attribute will be ignored.

      Overrides:
      getStyleName in class StatefulCanvas
      Returns:
      Current styleName value. Default value is "normal"
      See Also:
    • setTitle

      public void setTitle(String title)
      The title HTML to display in this button.

      If this method is called after the component has been drawn/initialized: Setter for the title.
      Overrides:
      setTitle in class StatefulCanvas
      Parameters:
      title - the new title HTML. Default value is "Untitled Button"
      See Also:
    • getTitle

      public String getTitle()
      The title HTML to display in this button.
      Overrides:
      getTitle in class StatefulCanvas
      Returns:
      Return the title - HTML drawn inside the component.

      Default is to simply return this.title. Default value is "Untitled Button"

      See Also:
    • setValign

      public Button setValign(VerticalAlignment valign)
      Vertical alignment of this component's title.

      If this method is called after the component has been drawn/initialized: Sets the vertical alignment of this buttons content.
      Overrides:
      setValign in class StatefulCanvas
      Parameters:
      valign - New valign value. Default value is Canvas.CENTER
      Returns:
      Button instance, for chaining setter calls
      See Also:
    • getValign

      public VerticalAlignment getValign()
      Vertical alignment of this component's title.
      Overrides:
      getValign in class StatefulCanvas
      Returns:
      Current valign value. Default value is Canvas.CENTER
      See Also:
    • setWidth

      public Button setWidth(Integer width)
      Size for this component's horizontal dimension. See Canvas.width for more details.

      Note that if StatefulCanvas.autoFit is set, this property will be ignored so that the widget is always sized just large enough to accommodate the title.

      Overrides:
      setWidth in class StatefulCanvas
      Parameters:
      width - New width value. Default value is null
      Returns:
      Button instance, for chaining setter calls
      See Also:
    • getWidth

      public Integer getWidth()
      Size for this component's horizontal dimension. See Canvas.width for more details.

      Note that if StatefulCanvas.autoFit is set, this property will be ignored so that the widget is always sized just large enough to accommodate the title.

      Overrides:
      getWidth in class StatefulCanvas
      Returns:
      Current width value. Default value is null
      See Also:
    • setWidth

      public void setWidth(String width)
      Size for this component's horizontal dimension. See Canvas.width for more details.

      Note that if StatefulCanvas.autoFit is set, this property will be ignored so that the widget is always sized just large enough to accommodate the title.

      Overrides:
      setWidth in class StatefulCanvas
      Parameters:
      width - New width value. Default value is null
      See Also:
    • getWidthAsString

      public String getWidthAsString()
      Size for this component's horizontal dimension. See Canvas.width for more details.

      Note that if StatefulCanvas.autoFit is set, this property will be ignored so that the widget is always sized just large enough to accommodate the title.

      Overrides:
      getWidthAsString in class StatefulCanvas
      Returns:
      Current width value. Default value is null
      See Also:
    • setWrap

      public Button setWrap(Boolean wrap)
      A boolean indicating whether the button's title should word-wrap, if necessary.

      If this method is called after the component has been drawn/initialized: Set whether the title of this button should be allowed to wrap if too long for the button's specified width.
      Parameters:
      wrap - whether to wrap the title. Default value is false
      Returns:
      Button instance, for chaining setter calls
    • getWrap

      public Boolean getWrap()
      A boolean indicating whether the button's title should word-wrap, if necessary.
      Returns:
      Current wrap value. Default value is false
    • action

      public void action()
      This property contains the default 'action' for the Button to fire when activated.
    • addToRadioGroup

      public void addToRadioGroup(String groupID)
      Add this widget to the specified mutually exclusive selection group with the ID passed in. Selecting this widget will then deselect any other StatefulCanvases with the same radioGroup ID. StatefulCanvases can belong to only one radioGroup, so this method will remove from any other radiogroup of which this button is already a member.
      Overrides:
      addToRadioGroup in class StatefulCanvas
      Parameters:
      groupID - - ID of the radiogroup to which this widget should be added
      See Also:
    • deselect

      public void deselect()
      Select this object.
      Overrides:
      deselect in class StatefulCanvas
      See Also:
    • addIconClickHandler

      public HandlerRegistration addIconClickHandler(IconClickHandler handler)
      Add a iconClick handler.

      If this button is showing an icon, a separate click handler for the icon may be defined as this.iconClick. Returning false will suppress the standard button click handling code.

      Specified by:
      addIconClickHandler in interface HasIconClickHandlers
      Parameters:
      handler - the iconClick handler
      Returns:
      HandlerRegistration used to remove this handler
    • removeFromRadioGroup

      public void removeFromRadioGroup()
      Remove this widget from the specified mutually exclusive selection group with the ID passed in. No-op's if this widget is not a member of the groupID passed in. If no groupID is passed in, defaults to removing from whatever radioGroup this widget is a member of.
      Overrides:
      removeFromRadioGroup in class StatefulCanvas
      See Also:
    • removeFromRadioGroup

      public void removeFromRadioGroup(String groupID)
      Remove this widget from the specified mutually exclusive selection group with the ID passed in. No-op's if this widget is not a member of the groupID passed in. If no groupID is passed in, defaults to removing from whatever radioGroup this widget is a member of.
      Overrides:
      removeFromRadioGroup in class StatefulCanvas
      Parameters:
      groupID - - optional radio group ID (to ensure the widget is removed from the appropriate group.
      See Also:
    • select

      public void select()
      Select this object.
      Overrides:
      select in class StatefulCanvas
      See Also:
    • titleClipped

      public boolean titleClipped()
      Is the title of this button clipped?
      Returns:
      whether the title is clipped.
    • addTitleHoverHandler

      public HandlerRegistration addTitleHoverHandler(TitleHoverHandler handler)
      Add a titleHover handler.

      Optional stringMethod to fire when the user hovers over this button and the title is clipped. If Button.showClippedTitleOnHover is true, the default behavior is to show a hover canvas containing the HTML returned by Button.titleHoverHTML(). Call TitleHoverEvent.cancel() from within TitleHoverHandler.onTitleHover(com.smartgwt.client.widgets.events.TitleHoverEvent) to suppress this default behavior.

      Specified by:
      addTitleHoverHandler in interface HasTitleHoverHandlers
      Parameters:
      handler - the titleHover handler
      Returns:
      HandlerRegistration used to remove this handler
    • titleHoverHTML

      public String titleHoverHTML(String defaultHTML)
      Returns the HTML that is displayed by the default titleHover handler. Return null or an empty string to cancel the hover.

      Use setTitleHoverFormatter() to provide a custom implementation.

      Parameters:
      defaultHTML - the HTML that would have been displayed by default. See HTMLString
      Returns:
      HTML to be displayed in the hover. If null or an empty string, then the hover is canceled. See HTMLString
      See Also:
    • setDefaultProperties

      public static void setDefaultProperties(Button buttonProperties)
      Class level method to set the default properties of this class. If set, then all existing and subsequently created instances of this class will automatically have default properties corresponding to the properties set on the SmartGWT class instance passed to this function before its underlying SmartClient JS object was created. This is a powerful feature that eliminates the need for users to create a separate hierarchy of subclasses that only alter the default properties of this class. Can also be used for skinning / styling purposes.

      Note: This method is intended for setting default attributes only and will affect all instances of the underlying class (including those automatically generated in JavaScript). This method should not be used to apply standard EventHandlers or override methods for a class - use a custom subclass instead. Calling this method after instances have been created can result in undefined behavior, since it bypasses any setters and a class instance may have already examined a particular property and not be expecting any changes through this route.

      Parameters:
      buttonProperties - properties that should be used as new defaults when instances of this class are created
      See Also:
    • setTitleHoverFormatter

      public void setTitleHoverFormatter(TitleHoverFormatter formatter)
      Provide a custom implementation of titleHoverHTML(java.lang.String).
    • assertIsButton

      public static void assertIsButton(Canvas targetCanvas, String message)
      Internal method to verify class of targetCanvas.
    • setLogicalStructure

      public LogicalStructureObject setLogicalStructure(ButtonLogicalStructure s)
      Setter implementing the LogicalStructure interface, which supports Eclipse's logical structure debugging facility.
    • getLogicalStructure

      public LogicalStructureObject getLogicalStructure()
      Getter implementing the LogicalStructure interface, which supports Eclipse's logical structure debugging facility.
      Specified by:
      getLogicalStructure in interface LogicalStructure
      Overrides:
      getLogicalStructure in class StatefulCanvas