* Fire node-* events when the selection is interacted. * * @param disableInteraction When true, have the provided selection * ignore all pointer events. Used for text labels inside of metanodes, which * don't need interaction as their surrounding shape has interaction, and if * given interactio
( selection, d: render.RenderNodeInfo, sceneElement: TfGraphScene, disableInteraction?: boolean )
| 277 | * given interaction would cause conflicts with the expand/collapse button. |
| 278 | */ |
| 279 | function addInteraction( |
| 280 | selection, |
| 281 | d: render.RenderNodeInfo, |
| 282 | sceneElement: TfGraphScene, |
| 283 | disableInteraction?: boolean |
| 284 | ) { |
| 285 | if (disableInteraction) { |
| 286 | selection.attr('pointer-events', 'none'); |
| 287 | return; |
| 288 | } |
| 289 | let contextMenuFunction = contextmenu.getMenu( |
| 290 | sceneElement, |
| 291 | getContextMenu(d.node, sceneElement) |
| 292 | ); |
| 293 | selection |
| 294 | .on('dblclick', (d) => { |
| 295 | sceneElement.fire('node-toggle-expand', {name: d.node.name}); |
| 296 | }) |
| 297 | .on('mouseover', (d) => { |
| 298 | // don't send mouseover over expanded group, |
| 299 | // otherwise it is causing too much glitches |
| 300 | if (sceneElement.isNodeExpanded(d)) { |
| 301 | return; |
| 302 | } |
| 303 | sceneElement.fire('node-highlight', {name: d.node.name}); |
| 304 | }) |
| 305 | .on('mouseout', (d) => { |
| 306 | // don't send mouseover over expanded group, |
| 307 | // otherwise it is causing too much glitches |
| 308 | if (sceneElement.isNodeExpanded(d)) { |
| 309 | return; |
| 310 | } |
| 311 | sceneElement.fire('node-unhighlight', {name: d.node.name}); |
| 312 | }) |
| 313 | .on('click', (d) => { |
| 314 | // Stop this event's propagation so that it isn't also considered |
| 315 | // a graph-select. |
| 316 | (<Event>d3.event).stopPropagation(); |
| 317 | sceneElement.fire('node-select', {name: d.node.name}); |
| 318 | }) |
| 319 | .on('contextmenu', (d, i) => { |
| 320 | sceneElement.fire('node-select', {name: d.node.name}); |
| 321 | contextMenuFunction.call(d, i); |
| 322 | }); |
| 323 | } |
| 324 | /** |
| 325 | * Returns the d3 context menu specification for the provided node. |
| 326 | */ |
no test coverage detected
searching dependent graphs…