首页 > 解决方案 > 我如何禁用 gojs 中的默认菜单

问题描述

我是新手gojs,当我在页面中按下手机屏幕 ( #myDiagram div) 时,会显示一些默认菜单,但我不想要它。

我尝试通过设置禁用它"toolManager.isEnable":false,但没有工作

 myDiagram =
        $(go.Diagram, "myDiagramDiv",
          {
            initialAutoScale: go.Diagram.Uniform,
            initialContentAlignment: go.Spot.Center,
            allowDrop: false,
            allowMove: false,
            "toolManager.isEnable":false,
            nodeSelectionAdornmentTemplate:
              $(go.Adornment, "Auto",
                { layerName: "Grid" }, 
                $(go.Placeholder)
              ),
            layout:  // use a custom layout, defined below
              $(GenogramLayout, { direction: 90, layerSpacing: 30, columnSpacing: 10 })
          });

我该如何禁用它?

这是按下后显示的内容
这是按下后显示的内容

标签: menugojs

解决方案


https://gojs.net/latest/intro/contextmenus.html#DefaultContextMenuForTouchEnabledDevices中所述,您只需将ContextMenuTool属性设置为 null。例如,在Diagram的初始化过程中:

$(go.Diagram, . . .,
  {
    "contextMenuTool.defaultTouchContextMenu": null
  })

推荐阅读