GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • @maxgraph/core

This view

  • Original page
  • New address

GeezerVison is showing maxgraph.github.io — EditorPopupMenu | @maxgraph/core

  • EditorPopupMenu

Class EditorPopupMenu

Creates popupmenus for mouse events.

This object holds an XML node which is a description of the popup menu to be created. In createMenu, the configuration is applied to the context and the resulting menu items are added to the menu dynamically. See createMenu for a description of the configuration format.

This class does not create the DOM nodes required for the popup menu, it only parses an XML description to invoke the respective methods on an MaxPopupMenu each time the menu is displayed.

Codec

This class uses the EditorPopupMenuCodec to read configuration data into an existing instance, however, the actual parsing is done by this class during program execution, so the format is described below.

  • Defined in editor/EditorPopupMenu.ts:41
Index

Constructors

constructor

Properties

config imageBasePath

Methods

addAction addItems createConditions createMenu

Constructors

constructor

  • new EditorPopupMenu(config?: Element | null): EditorPopupMenu

    Parameters

    • config: Element | null = null

    Returns EditorPopupMenu

    • Defined in editor/EditorPopupMenu.ts:42

Properties

config

config: Element | null

XML node used as the description of new menu items. This node is used in createMenu to dynamically create the menu items if their respective conditions evaluate to true for the given arguments.

  • Defined in editor/EditorPopupMenu.ts:56

imageBasePath

imageBasePath: string | null = null

Base path for all icon attributes in the config. Default is null.

Default

null
  • Defined in editor/EditorPopupMenu.ts:51

Methods

addAction

  • addAction(
        menu: MaxPopupMenu,
        editor: Editor,
        lab: string,
        icon?: string | null,
        funct?: Function | null,
        action?: string | null,
        cell?: Cell | null,
        parent?: PopupMenuItem | null,
        iconCls?: string | null,
        enabled?: boolean,
    ): PopupMenuItem

    Helper method to bind an action to a new menu item.

    Parameters

    • menu: MaxPopupMenu

      MaxPopupMenu that is used for adding items and separators.

    • editor: Editor

      Enclosing Editor instance.

    • lab: string

      String that represents the label of the menu item.

    • icon: string | null = null

      Optional URL that represents the icon of the menu item.

    • funct: Function | null = null

      Optional function to execute before the optional action. The function takes an , the under the mouse and the mouse event that triggered the call.

    • action: string | null = null

      Optional name of the action to execute in the given editor.

    • cell: Cell | null = null

      Optional to use as an argument for the action.

    • parent: PopupMenuItem | null = null

      DOM node that represents the parent menu item.

    • iconCls: string | null = null

      Optional CSS class for the menu icon.

    • enabled: boolean = true

      Optional boolean that specifies if the menu item is enabled. Default is true.

    Returns PopupMenuItem

    • Defined in editor/EditorPopupMenu.ts:261

addItems

  • addItems(
        editor: Editor,
        menu: MaxPopupMenu,
        cell?: Cell | null,
        evt?: MouseEvent | null,
        conditions: Record<string, boolean>,
        item: Element,
        parent?: PopupMenuItem | null,
    ): void

    Recursively adds the given items and all of its children into the given menu.

    Parameters

    • editor: Editor

      Enclosing Editor instance.

    • menu: MaxPopupMenu

      MaxPopupMenu that is used for adding items and separators.

    • cell: Cell | null = null

      Optional Cell which is under the mouse pointer.

    • evt: MouseEvent | null = null

      Optional mouse event which triggered the menu.

    • conditions: Record<string, boolean>

      Array of names boolean conditions.

    • item: Element

      XML node that represents the current menu item.

    • parent: PopupMenuItem | null = null

      DOM node that represents the parent menu item.

    Returns void

    • Defined in editor/EditorPopupMenu.ts:178

createConditions

  • createConditions(
        editor: Editor,
        cell?: Cell | null,
        evt?: MouseEvent | null,
    ): Record<string, boolean>

    Evaluates the default conditions for the given context.

    Parameters

    • editor: Editor
    • cell: Cell | null = null
    • evt: MouseEvent | null = null

    Returns Record<string, boolean>

    • Defined in editor/EditorPopupMenu.ts:291

createMenu

  • createMenu(
        editor: Editor,
        menu: MaxPopupMenu,
        cell?: Cell | null,
        evt?: MouseEvent | null,
    ): void

    This function is called from Editor to add items to the given menu based on config. The config is a sequence of the following nodes and attributes.

    @ChildNodes:

    add - Adds a new menu item. See below for attributes. separator - Adds a separator. No attributes. condition - Adds a custom condition. Name attribute.

    The add-node may have a child node that defines a function to be invoked before the action is executed (or instead of an action to be executed).

    @Attributes:

    as - Resource key for the label (needs entry in property file). action - Name of the action to execute in enclosing editor. icon - Optional icon (relative/absolute URL). iconCls - Optional CSS class for the icon. if - Optional name of condition that must be true (see below). enabled-if - Optional name of condition that specifies if the menu item should be enabled. name - Name of custom condition. Only for condition nodes.

    @Conditions:

    nocell - No cell under the mouse. ncells - More than one cell selected. notRoot - Drilling position is other than home. cell - Cell under the mouse. notEmpty - Exactly one cell with children under mouse. expandable - Exactly one expandable cell under mouse. collapsable - Exactly one collapsable cell under mouse. validRoot - Exactly one cell which is a possible root under mouse. swimlane - Exactly one cell which is a swimlane under mouse.

    @Example:

    To add a new item for a given action to the popupmenu:

    <EditorPopupMenu as="popupHandler">
    <add as="delete" action="delete" icon="images/delete.gif" if="cell"/>
    </EditorPopupMenu>

    To add a new item for a custom function:

    <EditorPopupMenu as="popupHandler">
    <add as="action1"><![CDATA[
    function (editor, cell, evt)
    {
    editor.execute('action1', cell, 'myArg');
    }
    ]]></add>
    </EditorPopupMenu>

    The above example invokes action1 with an additional third argument via the editor instance. The third argument is passed to the function that defines action1. If the add-node has no action-attribute, then only the function defined in the text content is executed, otherwise first the function and then the action defined in the action-attribute is executed. The function in the text content has 3 arguments, namely the Editor instance, the Cell instance under the mouse, and the native mouse event.

    Custom Conditions:

    To add a new condition for popupmenu items:

    <condition name="condition1"><![CDATA[
    function (editor, cell, evt)
    {
    return cell != null;
    }
    ]]></condition>

    The new condition can then be used in any item as follows:

    <add as="action1" action="action1" icon="action1.gif" if="condition1"/>
    

    The order in which the items and conditions appear is not significant as all conditions are evaluated before any items are created.

    Parameters

    • editor: Editor

      Enclosing Editor instance.

    • menu: MaxPopupMenu

      MaxPopupMenu that is used for adding items and separators.

    • cell: Cell | null = null

      Optional Cell which is under the mouse pointer.

    • evt: MouseEvent | null = null

      Optional mouse event which triggered the menu.

    Returns void

    • Defined in editor/EditorPopupMenu.ts:154

Settings

Member Visibility
  • Protected
  • Inherited
Theme

On This Page

Codec
Constructors
constructor
Properties
configimageBasePath
Methods
addActionaddItemscreateConditionscreateMenu
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.