HTMLInfo class

HTMLInfo is used to show and hide custom HTML page elements, such as a context menu, tooltip, or text editor made of HTML.

Properties that can be set to an HTMLInfo include:

  • TextEditingTool#defaultTextEditor
  • TextBlock#textEditor
  • GraphObject#contextMenu
  • Diagram#contextMenu
  • GraphObject#toolTip
  • Diagram#toolTip

When a context menu is set to an instance of HTMLInfo, ContextMenuTool#showContextMenu and ContextMenuTool#hideContextMenu call #show and #hide respectively. You may define #mainElement instead of #hide in order to automatically use a default hide method.

When a tooltip is set to an instance of HTMLInfo, ToolManager#showToolTip and ToolManager#hideToolTip call #show and #hide respectively.

When a text editor is set to an instance of HTMLInfo, TextEditingTool#doActivate calls #show and TextEditingTool#doDeactivate calls #hide.

For HTMLInfo to work, you must define #show and either #hide or #mainElement. Typical usage will also stop the ContextMenuTool once the desired context action occurs, typically by calling diagram.currentTool.stopTool();.

Example usage of HTMLInfo can be found in the Custom Context Menu and HTML LightBox Context Menu samples, the Custom TextEditingTool sample, and the Text Editor implementation extension.

Here is the outline for typical usage of HTMLInfo as a context menu:

// Assign an HTMLInfo to the Diagram:
myDiagram.contextMenu = $(go.HTMLInfo, {
  show: showContextMenu,
  hide: hideContextMenu
});

function showContextMenu(obj, diagram, tool) {
  // Show the context menu HTML element:
  SomeDOMElement.style.display = "block";

  // Also show relevant buttons given the current state
  // and the GraphObject obj; if null, the context menu is for the whole Diagram
}

function hideContextMenu() {
  SomeDOMElement.style.display = "none";
}

function buttonClick() {
  // do some action when a context menu button is clicked

  // then:
  myDiagram.currentTool.stopTool();
}

By default, TextEditingTool#defaultTextEditor is an instance of HTMLInfo. You can see its default implementation details here.

Available Extensions
Annotations
  • @JS()
  • @staticInterop

Constructors

HTMLInfo()
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited