Request

Response

    Autodesk.Viewing.UI

    Button

    new Button(id, options)

    Button control that can be added to toolbars.

    Parameters

    Expand all
    id
    string
    The ID for this button. Optional.
    options
    object
    An optional dictionary of options.
    collapsible
    boolean
    Whether this button is collapsible.

    Properties

    State
    Number
    Enum for button states

    Methods

    setState(state)

    Sets the state of this button.

    Parameters

    state*The state.
    * Required

    Returns

    typedescription
    boolean True if the state was set successfully.

    setIcon(iconClass)

    Sets the icon for the button.

    Parameters

    iconClass*
    string
    The CSS class defining the appearance of the button icon (e.g. image background).
    * Required

    getState()

    Returns the state of this button.

    Returns

    typedescription
    Autodesk.Viewing.UI.Button.State The state of the button.

    onClick(event)

    Override this method to be notified when the user clicks on the button.

    Parameters

    event*
    MouseEvent
    * Required

    onMouseOver(event)

    Override this method to be notified when the mouse enters the button.

    Parameters

    event*
    MouseEvent
    * Required

    onMouseOut(event)

    Override this method to be notified when the mouse leaves the button.

    Parameters

    event*
    MouseEvent
    * Required

    getId()

    Gets this control’s ID.

    Returns

    typedescription
    string The control’s ID.

    setVisible(visible)

    Sets the visibility of this control.

    Parameters

    visible*
    boolean
    The visibility value to set.
    * Required

    Returns

    typedescription
    boolean True if the control’s visibility changed.

    isVisible()

    Gets the visibility of this control.

    Returns

    typedescription
    boolean True if the this control is visible.

    setToolTip(toolTipText)

    Sets the tooltip text for this control.

    Parameters

    toolTipText*
    string
    The text for the tooltip.
    * Required

    Returns

    typedescription
    boolean True if the tooltip was successfully set.

    getToolTip()

    Returns the tooltip text for this control.

    Returns

    typedescription
    string The tooltip text. Null if it’s not set.

    setCollapsed(collapsed)

    Sets the collapsed state of this control.

    Parameters

    collapsed*
    boolean
    The collapsed value to set.
    * Required

    Returns

    typedescription
    boolean True if the control’s collapsed state changes.

    isCollapsed()

    Gets the collapsed state of this control.

    Returns

    typedescription
    boolean True if this control is collapsed.

    isCollapsible()

    Returns whether or not this control is collapsible.

    Returns

    typedescription
    boolean True if this control can be collapsed.

    addClass(cssClass)

    Adds a CSS class to this control.

    Parameters

    cssClass*
    string
    The name of the CSS class.
    * Required

    removeClass(cssClass)

    Removes a CSS class from this control.

    Parameters

    cssClass*
    string
    The name of the CSS class.
    * Required

    getPosition()

    Returns the position of this control relative to the canvas.

    Returns

    typedescription
    object The top and left values of the toolbar.

    getDimensions()

    Returns the dimensions of this control.

    Returns

    typedescription
    object The width and height of the toolbar.

    setDisplay(value)

    Sets the CSS display style value.

    Parameters

    value*
    string
    CSS display value
    * Required

    removeFromParent()

    Removes current control from its parent container.

    Returns

    typedescription
    boolean True if the control was successfully removed.

    Events

    STATE_CHANGED

    Event fired when state of the button changes.

    Properties

    buttonId
    string
    The ID of the button that fired this event.
    stateThe new state of the button.

    VISIBILITY_CHANGED

    Event fired when the visibility of the control changes.

    Properties

    controlId
    string
    The ID of the control that fired this event.
    isVisible
    boolean
    True if the control is now visible.

    COLLAPSED_CHANGED

    Event fired when the collapsed state of the control changes.

    Properties

    controlId
    string
    The ID of the control that fired this event.
    isCollapsed
    boolean
    True if the control is now collapsed.