Set movable: true or false with click of btn

I want to restrict move permission of a node by click of a btn and grant the permission back by the next click.

I am trying some logic as follows:

movable: returnTrueFalse,

var _flag = 1;
var returnTrueFalse = function () {
var value;
if (_flag === 1) {
value = “true”;
_flag = 0;
console.log(_flag + " " + value);
} else {
value = “false”;
_flag = 1;
console.log(_flag + " " + value);
return value;

this is not showing error but the is also setting the value for movable false.

is there any other way of toggling movable true false?

You didn’t say whether it’s a button in the Node, in an Adornment on the Node, or in some HTML.

The basic idea would be:

// somehow get the Node, either:
//   button.part, if it's a click event handler of a button in the Node, or
//   button.part.adornedPart, if it's a click event handler of a button in an Adornment on the Node, or
//   ??? only you know, if you have implemented an HTML button.
node = ...
node.diagram.commit(d => node.movable = !node.movable);

I want it to be part of adornment

margin: 15,
height: 26,
width: 26,
“ButtonBorder.fill”: “#00D1FF”,
“ButtonBorder.stroke”: null,
click: function (e, button) {
e.diagram.commit(function (d) {
}, “deleted node”);
$(go.Picture, “./trash.svg”, {})

I am using the above code to remove node, how will it be in terms of making non movable and movable?

I showed the code in my previous post.

Able to do it in all three options provided, Thanks Walter!