Diagram nodeTemplate define mouseDown handler

Hey,

I want to setup a mouseDown handler for nodes within a diagram. I’ve set up the template using the following approach:

$(go.Node, 'Auto',
    {
        isActionable: true,
        actionDown: function () {
            //Dance like a ninja ;)
        }
    }
    $(go.Shape, 'Rectangle', {
        fill: '#FFF',
        width: 10,
        height: 10
    }),
    new go.Binding('location', 'latlong', calcDiagramLocation.bind(this, map))
);

But this approach has the effect, that the default behavior of selecting the node won’t be executed. I simply want to add additional behavior.

Are you sure you don’t want to establish a GraphObject.click event handler?

The problem is that a mouse-down event could mean any number of things. The choice is determined by which Tool can start running. That’s what the ToolManager is responsible for managing.

Well I’m not 100% sure :-) . I suppose you do have a better idea. All I want to do is lock dragging operations in my map when I select a node. I want this behavior to be able to select a node and move it freely within my map. After the operation I want to reenable the dragging operations of my map.

Here’s the example I’m working on. Take a look at the script.js file.

What do you mean by “dragging operations … when I select a node”?

You apparently do not mean setting DraggingTool.isEnabled to false when some node is selected, because then you talk about being able to “select a node and move it freely”.

Hmmm, then I’ll guess that you mean disabling panning. That would normally mean setting PanningTool.isEnabled to false. myDiagram.toolManager.panningTool.isEnabled = false;

However, if I recall correctly, you’re using Leaflet, aren’t you? The event handling is different there. Simon is working on improving our sample integration with Leaflet to allow moving a node. (Although not today – we’re a bit busy doing other things.)

Thank’s for the reply. I really appreciate your support :+1: . I’ve solved this issue for desktop devices using the mouseEnter and mouseLeave handlers on the nodeTemplate of the diagram.