Class BaseWidgetAbstract

The abstract base class for items that can be shown in a js-draw toolbar. See also AbstractToolbar.addWidget.

See the custom tool example for how to create a custom toolbar widget for a tool.

For custom action buttons, AbstractToolbar.addActionButton may be sufficient for most use cases.

Hierarchy (View Summary)

Constructors

Properties

container: HTMLElement
editor: Editor
id: string
localizationTable: ToolbarLocalization

Accessors

Methods

  • Only used by some layout managers. In those layout managers, makes this dropdown visible.

    Returns void

  • Returns true iff this widget can be in a nontoplevel menu.

    Returns boolean

    Use !mustBeInToplevelMenu() instead.

  • Restore widget state from serialized data. See also saveState.

    Overriders must call super.

    Parameters

    • state: SavedToolbuttonState

    Returns void

  • Add content to the widget's associated dropdown menu. Returns true if such a menu should be created, false otherwise.

    Parameters

    • dropdown: HTMLElement
    • OptionalhelpDisplay: HelpDisplay

    Returns boolean

  • Should return a 1-2 sentence description of the widget.

    At present, this is only used if this widget has an associated dropdown.

    Returns undefined | string

  • Returns the ID of this widget in container. Adds a suffix to this' ID if an item in container already has this' ID.

    For example, if this has ID foo and if container = { 'foo': somethingNotThis, 'foo-1': somethingElseNotThis }, this method returns foo-2 because elements with IDs foo and foo-1 are already present in container.

    If this is already in container, returns the id given to this in the container.

    Parameters

    Returns string

  • Returns true if this widget must always be in a toplevel menu and not in a scrolling/overflow menu.

    This method can be overidden to override the default of true.

    Returns boolean

  • Serialize state associated with this widget. Override this method to allow saving/restoring from state on application load.

    Overriders should call super and include the output of super.serializeState in the output dictionary.

    Clients should not rely on the output from saveState being in any particular format.

    Returns SavedToolbuttonState

  • Note: Tags should be set before a tool widget is added to a toolbar.

    Associates tags with this widget that can be used by toolbar themes to customize the layout/appearance of this button. Prefer tags in the ToolbarWidgetTag enum, where possible.

    In addition to being readable from the getTags method, tags are added to a button's main container as CSS classes with the toolwidget-tag-- prefix.

    For example, the undo tag would result in toolwidget-tag--undo being added to the button's container's class list.

    Parameters

    • tags: string[]

    Returns void

  • Parameters

    • button: HTMLElement

    Returns void

    Renamed to setUpButtonEventListeners.

  • Should return a constant true or false value. If true (the default), this widget must be automatically disabled when its editor is read-only.

    Returns boolean

OpenSource licenses