Request

Response

    UI

    Autodesk.Viewing.UI.SettingsPanel

    Extends DockingPanel

    new SettingsPanel(parentContainer,id,title,options)

    UI panel specifically designed for application settings.

    The user can add new options to each of the tabs.

    Parameters

    parentContainer*
    HTMLElement
    The container for this panel.
    id*
    string
    The id to assign this panel.
    title*
    string
    The title of this panel.
    options
    object
    An optional dictionary of options.
    * Required

    Methods

    addCheckbox(tabId,caption,initialState,onchange,options)

    Creates a checkbox control and adds it to a given tab.

    Parameters

    tabId*
    string
    Tab to which to add a new checkbox.
    caption*
    string
    The text associated with the checkbox.
    initialState*
    boolean
    Initial value for the checkbox (checked or not).
    onchange*
    function
    Callback that is called when the checkbox is changed.
    options*
    object|undefined
    Additional options:
    • insertAtIndex - index at which to insert a new checkbox
    * Required

    Returns

    TypeDescription
    string ID of a new control.

    addControl(tabId,control,options)

    Adds a new control to a given tab.

    Parameters

    tabId*
    string
    Tab to which to add a new.
    control*
    object|HTMLElement
    Control to add to the given tab.
    options*
    object|undefined
    Additional parameters:
    • insertAtIndex - index at which to insert a new control
    • caption - caption for the control
    * Required

    Returns

    TypeDescription
    string ID of the added control.

    addDropDownMenu(tabId,caption,items,initialItemIndex,onchange,options)

    Parameters

    tabId*
    string
    Tab to which to add a new slider.
    caption*
    string
    The text associated with the slider.
    items*
    array
    List of items for the menu.
    initialItemIndex*
    number
    Initial choice.
    onchange*
    function
    Callback that is called when the menu selection is changed.
    options*
    object|undefined
    Additional options:
    • insertAtIndex - index at which to insert a new drop down menu
    * Required

    Returns

    TypeDescription
    string ID of a new control.

    addEventListener(target,eventId,callback)

    Adds an event listener to a given target that has an addEventListener(event, callback) API. These event listeners are tracked by the DockingPanel and are automatically removed on uninitialize.

    Parameters

    target*
    object
    The target that will fire the event.
    eventId*
    string
    The event to be listened to.
    callback*
    function
    The callback to execute when the event is fired.
    * Required

    addSlider(tabId,caption,min,max,initialValue,onchange,options)

    Creates a slider control and adds it to a given tab.

    Parameters

    tabId*
    string
    Tab to which to add a new slider.
    caption*
    string
    The text associated with the slider
    min*
    number
    Min value of the slider.
    max*
    number
    Max value of the slider.
    initialValue*
    number
    Initial value for the slider.
    onchange*
    function
    Callback that is called when the slider value is changed.
    options*
    object|undefined
    Additional options:
    • insertAtIndex - index at which to insert a new slider
    * Required

    Returns

    TypeDescription
    string ID of a new control.

    addTab(tabId,tabTitle,options)

    Adds a new tab to the panel.

    Parameters

    tabId*
    string
    id for the tab (DOM element will have an extended ID to ensure uniqueness).
    tabTitle*
    string
    options
    object
    optional parameter that allows for additional options for the tab:
    • tabClassName - class name for the Dom elements
    • minWidth - min width for the tab
    • index - index if the tab should be inserted instead of added at the end.
    * Required

    Returns

    TypeDescription
    boolean True if the tab was added to the panel, false otherwise.

    addVisibilityListener(callback)

    Adds a callback to call when this DockingPanel changes visibility.

    Parameters

    callback*
    function
    A function that takes in a single boolean parameter indicating the current visibility state.
    * Required

    createCloseButton()

    Creates a close button to add to this DockingPanel. When clicked, this DockingPanel is hidden. Call this method during initialize() if a standard close button is desired, and then add it to an existing container.

    Returns

    TypeDescription
    HTMLElement The created close button.

    createScrollContainer(options)

    Creates a scroll container element to add to this DockingPanel. Call this method during initialize() if a scroll container is needed. The function will create the scroll container and make it available via the “scrollContainer” property of the DockingPanel.

    Parameters

    Expand all
    options
    object
    An optional dictionary of options.
    left
    boolean
    When true, the scrollbar appears on the left.
    heightAdjustment
    number
    The scroll container height is 100% of the panel minus the height adjustment. Provide a value to account for other elements in the panel like a title bar.
    marginTop
    number
    The marginTop setting for the scroll container’s CSS style, in pixels.

    createTitleBar(title)

    Inherits createTitleBar

    Creates a title bar element to add to this DockingPanel. Call this method during initialize() if a standard title bar is desired, and then add it to an existing container.

    Parameters

    title*
    string
    The text to use in the title bar.
    * Required

    Returns

    TypeDescription
    HTMLElement The created title bar.

    getContainerBoundingRect()

    Returns the parent’s container bounding rectangle.

    Returns

    TypeDescription
    ClientRect Bounding rectangle of the parent.

    getContentSize()

    Returns the width and height to be used when resizing the panel to the content.

    Returns

    TypeDescription
    object {height: number, width: number}.

    getControl(controlId)

    Returns a control with a given id.

    Parameters

    controlId*
    string
    Checkbox id to return.
    * Required

    Returns

    TypeDescription
    object Control object if found, null otherwise.

    hasTab(tabId)

    Returns true if a tab with given id exists.

    Parameters

    tabId*
    string
    Tab id.
    * Required

    Returns

    TypeDescription
    boolean True if the tab with given id exists, false otherwise.

    initialize()

    Inherits initialize

    Creates the sub-elements of this DockingPanel. Override this in derived classes. The default implementation is to create a title bar with the title or id provided in the constructor. The title bar also acts as the move handler for the DockingPanel. Finally, a close button is added to the top right corner.

    initializeCloseHandler(closer)

    Initializes the given HTMLDomElement as the close handle for this DockingPanel. When this element is clicked, this DockingPanel is hidden.

    Parameters

    closer*
    HTMLElement
    The DOM element that will act as the close handle.
    * Required

    initializeMoveHandlers(mover)

    Initializes the given HTMLDomElement as the move handle for this DockingPanel. When this element is clicked and dragged, this DockingPanel is moved.

    Parameters

    mover*
    HTMLElement
    The DOM element that will act as the move handle.
    * Required

    isTabSelected(tabId)

    Returns true if the given tab is selected (visible).

    Parameters

    tabId*
    string
    Tab to check.
    * Required

    Returns

    TypeDescription
    boolean True if the tab is selected, false otherwise.

    isVisible()

    Inherits isVisible

    Gets the new visibility state of this DockingPanel.

    Returns

    TypeDescription
    boolean Whether or not the panel is visible.

    onEndMove(event,endX,endY)

    Inherits onEndMove

    Override this event to be notified when this panel ends a move operation.

    Parameters

    event*
    MouseEvent
    The mouseup event.
    endX*
    number
    The ending x position of the panel in pixels.
    endY*
    number
    The ending y position of the panel in pixels.
    * Required

    onMove(event,currentX,currentY)

    Inherits onMove

    Override this to be notified when this panel is moved. Note, do not forget to call this base class method in the overriding method.

    Parameters

    event*
    MouseEvent
    The mousemove event.
    currentX*
    number
    The current x position of the panel in pixels.
    currentY*
    number
    The current y position of the panel in pixels.
    * Required

    onStartMove(event,startX,startY)

    Inherits onStartMove

    Override this event to be notified when this panel begins a move operation.

    Parameters

    event*
    MouseEvent
    The mousedown event.
    startX*
    number
    The starting x position of the panel in pixels.
    startY*
    number
    The starting y position of the panel in pixels.
    * Required

    onTitleClick(event)

    Inherits onTitleClick

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

    Parameters

    event*
    Event
    * Required

    onTitleDoubleClick(event)

    Override this method to be notified when the user double-clicks on the title.

    Parameters

    event*
    Event
    * Required

    removeCheckbox(checkboxId)

    Removes a given checkbox from the settings panel.

    Parameters

    checkboxId*
    string|Control
    Checkbox to remove.
    * Required

    Returns

    TypeDescription
    boolean True if the checkbox was removed, false otherwise.

    removeControl(controlId)

    Removes a given control from the settings panel.

    Parameters

    controlId*
    string|Control
    The control ID or control instance to remove.
    * Required

    Returns

    TypeDescription
    boolean true if the control was removed, false if the control was not removed.

    removeDropdownMenu(dropdownMenuId)

    Removes a given dropdown menu from the settings panel.

    Parameters

    dropdownMenuId*
    string|Control
    Dropdown to remove.
    * Required

    Returns

    TypeDescription
    boolean true if the dropdown was removed, false if the dropdown was not removed.

    removeEventListener(target,eventId,callback)

    Removes an existing event listener added using DockingPanel.addEventListener.

    Parameters

    target*
    object
    The target with the event listener.
    eventId*
    string
    The id of the event being listened to.
    callback*
    function
    The callback executed when the event is fired.
    * Required

    Returns

    TypeDescription
    boolean True if the listener was removed successfully; false otherwise.

    removeSlider(sliderId)

    Removes a given slider from the settings panel.

    Parameters

    sliderId*
    string|Control
    Slider control to remove.
    * Required

    Returns

    TypeDescription
    boolean True if the slider control was removed, false otherwise.

    removeTab(tabId)

    Removes the given tab from the panel.

    Parameters

    tabId*
    string
    Tab to remove.
    * Required

    Returns

    TypeDescription
    boolean True if the tab was successfully removed, false otherwise.

    resizeToContent(options)

    Inherits resizeToContent

    Resizes the panel to the current content. Currently this only works on height.

    Parameters

    Expand all
    options
    object
    An optional dictionary of options.
    maxHeight
    number
    The maximum height to resize this panel.

    selectTab(tabId)

    Makes a given tab visible and hides the other ones.

    Parameters

    tabId*
    string
    Tab to select.
    * Required

    Returns

    TypeDescription
    boolean True if the tab was selected, false otherwise.

    setTitle(text,options)

    Inherits setTitle

    Sets the title for this panel.

    Parameters

    Expand all
    text*
    string
    The title for this panel.
    options
    Object
    An optional dictionary of options.
    localizeTitle
    boolean
    When true, localization is attempted for the given text.
    * Required

    setVisible(show,skipTransition)

    Sets the new visibility state of this SettingsPanel.

    Parameters

    show*
    boolean
    The desired visibility state.
    skipTransition*
    boolean
    If true, skips initial opaque state and displays directly with final background color.
    * Required

    uninitialize()

    Inherits uninitialize

    Performs any clean up necessary. This can include disconnecting UI elements, unregistering event callbacks, etc.

    visibilityChanged()

    Notification that visibility has been changed by external sources.