Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MaxToolbar

Creates a toolbar inside a given DOM node. The toolbar may contain icons, buttons and combo boxes.

Event: mxEvent.SELECT

Fires when an item was selected in the toolbar. The function property contains the function that was selected in .

Hierarchy

Index

Constructors

constructor

  • new MaxToolbar(container: HTMLElement): MaxToolbar

Properties

container

container: HTMLElement

Reference to the DOM nodes that contains the toolbar.

currentImg

currentImg: null | HTMLButtonElement | HTMLImageElementWithProps = null

defaultFunction

defaultFunction: null | Function = null

defaultMode

defaultMode: null | HTMLButtonElement | HTMLImageElementWithProps = null

enabled

enabled: boolean = true

Specifies if events are handled. Default is true.

eventListeners

eventListeners: EventListenerObject[] = []

Holds the event names and associated listeners in an array. The array contains the event name followed by the respective listener for each registered listener.

eventSource

eventSource: null | EventTarget = null

Optional source for events. Default is null.

eventsEnabled

eventsEnabled: boolean = true

Specifies if events can be fired. Default is true.

menu

menu: null | MaxPopupMenu = null

noReset

noReset: boolean = false

Specifies if requires a forced flag of true for resetting the current mode in the toolbar. Default is false. This is set to true if the toolbar item is double clicked to avoid a reset after a single use of the item.

selectedMode

selectedMode: null | HTMLImageElementWithProps = null

updateDefaultMode

updateDefaultMode: boolean = true

Boolean indicating if the default mode should be the last selected switch mode or the first inserted switch mode. Default is true, that is the last selected switch mode is the default mode. The default mode is the mode to be selected after a reset of the toolbar. If this is false, then the default mode is the first inserted mode item regardless of what was last selected. Otherwise, the selected item after a reset is the previously selected item.

Methods

addActionCombo

  • addActionCombo(title: string, style?: string): HTMLSelectElement
  • Adds and returns a new SELECT element using the given title as the default element. The selection is reset to this element after each change.

    Parameters

    • title: string

      String that specifies the title of the default element.

    • Optional style: string

      Optional style classname. Default is mxToolbarCombo.

    Returns HTMLSelectElement

addBreak

  • addBreak(): void

addCombo

  • addCombo(style?: string): HTMLSelectElement
  • Adds and returns a new SELECT element using the given style. The element is placed inside a DIV with the mxToolbarComboContainer style classname.

    Parameters

    • Optional style: string

      Optional style classname. Default is mxToolbarCombo.

    Returns HTMLSelectElement

addItem

  • addItem(title?: null | string, icon?: null | string, funct?: null | MouseEventListener | KeyboardEventListener, pressedIcon?: null | string, style?: null | string, factoryMethod?: null | ((handler: PopupMenuItem, cell: null | Cell, me: MouseEvent) => void)): HTMLImageElement | HTMLButtonElement
  • Adds the given function as an image with the specified title and icon and returns the new image node.

    Parameters

    • title: null | string = null

      Optional string that is used as the tooltip.

    • icon: null | string = null

      Optional URL of the image to be used. If no URL is given, then a button is created.

    • funct: null | MouseEventListener | KeyboardEventListener = null

      Function to execute on a mouse click.

    • pressedIcon: null | string = null

      Optional URL of the pressed image. Default is a gray background.

    • style: null | string = null

      Optional style classname. Default is mxToolbarItem.

    • factoryMethod: null | ((handler: PopupMenuItem, cell: null | Cell, me: MouseEvent) => void) = null

      Optional factory method for popup menu, eg. (menu, evt, cell)=> { menu.addItem('Hello, World!'); }

    Returns HTMLImageElement | HTMLButtonElement

addLine

  • addLine(): void

addListener

  • addListener(name: string, funct: Function): void
  • Binds the specified function to the given event name. If no event name is given, then the listener is registered for all events.

    The parameters of the listener are the sender and an EventObject.

    Parameters

    • name: string
    • funct: Function

    Returns void

addMode

  • addMode(title?: null | string, icon?: null | string, funct: Function, pressedIcon: string, style?: null | string, toggle?: boolean): HTMLImageElementWithProps
  • Adds a new item to the toolbar. The selection is typically reset after the item has been consumed, for example by adding a new vertex to the graph. The reset is not carried out if the item is double clicked.

    The function argument uses the following signature: funct(evt, cell) where evt is the native mouse event and cell is the cell under the mouse.

    Parameters

    • title: null | string = null
    • icon: null | string = null
    • funct: Function
    • pressedIcon: string
    • style: null | string = null
    • toggle: boolean = false

    Returns HTMLImageElementWithProps

addOption

  • addOption(combo: HTMLSelectElement, title: string, value?: null | string | ((evt: any) => void)): HTMLOptionElement
  • Adds and returns a new OPTION element inside the given SELECT element. If the given value is a function then it is stored in the option's funct field.

    Parameters

    • combo: HTMLSelectElement

      SELECT element that will contain the new entry.

    • title: string

      String that specifies the title of the option.

    • value: null | string | ((evt: any) => void) = null

      Specifies the value associated with this option.

    Returns HTMLOptionElement

addSeparator

  • addSeparator(icon: string): HTMLImageElement | HTMLButtonElement
  • Adds the specifies image as a separator.

    Parameters

    • icon: string

      URL of the separator icon.

    Returns HTMLImageElement | HTMLButtonElement

addSwitchMode

  • addSwitchMode(title: string, icon: string, funct: () => void, pressedIcon?: null | string, style?: string): HTMLImageElementWithProps
  • Adds a new selectable item to the toolbar. Only one switch mode item may be selected at a time. The currently selected item is the default item after a reset of the toolbar.

    Parameters

    • title: string
    • icon: string
    • funct: () => void
        • (): void
        • Returns void

    • pressedIcon: null | string = null
    • style: string = 'mxToolbarMode'

    Returns HTMLImageElementWithProps

destroy

  • destroy(): void

fireEvent

  • fireEvent(evt: EventObject, sender?: null | EventTarget): void
  • Dispatches the given event to the listeners which are registered for the event. The sender argument is optional. The current execution scope ("this") is used for the listener invocation (see {@link Utils#bind}).

    Example:

    fireEvent(new mxEventObject("eventName", key1, val1, .., keyN, valN))
    

    Parameters

    • evt: EventObject

      EventObject that represents the event.

    • sender: null | EventTarget = null

      Optional sender to be passed to the listener. Default value is the return value of .

    Returns void

getEventSource

  • getEventSource(): null | EventTarget

isEventsEnabled

  • isEventsEnabled(): boolean

removeListener

  • removeListener(funct: Function): void

resetMode

  • resetMode(forced?: boolean): void
  • Selects the default mode and resets the state of the previously selected mode.

    Parameters

    • forced: boolean = false

    Returns void

selectMode

  • selectMode(domNode: HTMLImageElement, funct?: null | Function): void
  • Resets the state of the previously selected mode and displays the given DOM node as selected. This function fires a select event with the given function as a parameter.

    Parameters

    • domNode: HTMLImageElement
    • funct: null | Function = null

    Returns void

setEventSource

  • setEventSource(value: null | EventTarget): void

setEventsEnabled

  • setEventsEnabled(value: boolean): void

Generated using TypeDoc