Get node key in called function on click


I would like to call a function when a node is clicked and send the function called the key of the clicked node. I have the first part that calls the function. I can also receive something in the called function but I do not know how to get the key from the node object in the called function.

How do I get the key?

Here is the node information and the called function:

myDiagram.nodeTemplate =
graphObjectMake(go.Node, “Table”,
<span =“Apple-tab-span” style=“white-space:pre”> click: getNodeData
{ locationObjectName: “BODY”,
locationSpot: go.Spot.Center,
selectionObjectName: “BODY”,
graphObjectMake(go.Adornment, “Auto”,
graphObjectMake(go.Shape, “Rectangle”,
{ stroke: “dodgerblue”,
strokeWidth: 3,
fill: null }),

            mouseDragLeave: function (e, node, next) {
            mouseDrop: function (e, node) {
        new go.Binding("key", "text", go.Point.parse).makeTwoWay(go.Point.stringify),

        // the body
        graphObjectMake(go.Panel, "Auto",
            { row: 1, column: 1, name: "BODY",
                stretch: go.GraphObject.Fill },
                graphObjectMake(go.Shape, "RoundedRectangle",
                { fill: "blue",
                    minSize: new go.Size(135, 65) },
                new go.Binding("fill", "color").makeTwoWay()),
                graphObjectMake(go.Panel, "Table",
                {maxSize: new go.Size(135, 65),
                    defaultAlignment: go.Spot.Center },
                graphObjectMake(go.RowColumnDefinition, { column: 1, row: 3, width: 10 }),
                    { margin: 5,
                        row: 1, column: 0,
                        editable: false,
                        font: "11pt sans-serif",
                        textAlign: "center" },
                    new go.Binding("text", "name").makeTwoWay())

<span =“Apple-tab-span” style=“white-space:pre”> )
) // end Auto Panel body
); // end Node

function getNodeData(node)

<span =“Apple-tab-span” style=“white-space:pre”> //<span =“Apple-tab-span” style=“white-space:pre”> <How do I get the key of the node variable?>
var sd = “dsafhj”;
var hg = sd;


Lots of samples do things like that. Have you searched the samples?

For example, does something similar to what you want, except that it uses doubleClick instead of click.

Also, please read for more information about event handlers such as

Thanks Walter!

Based on where you pointed me, I have two examples here if anyone else runs into this issue.

Example of calling a function on click in the nodetemplate of the diagram.
{ click: function(e, obj) { getNodeData("Clicked on " +; }},

Example of using a listener:

function(e) {
var part = e.subject.part;
<span =“apple-tab-span”="" style=“white-space:pre”> // is the node object
if (!(part instanceof go.Link)) getNodeData1("Clicked on " +;