Hi! I’m quite confused as to why a mouseDrop event is executing from one Node but not another Node when I drop a Palette Node onto them… and the mouseDrags work on both as expected…
One thing to note, if it matters, is that the Palette and Diagram Node templates (white background) are the same.
This Node executes as expected (white background):
const docletTypeNodes = $(
go.Node,
'Auto',
new go.Binding(
'copyable',
'',
(event: go.ObjectData) => event.state !== GoJsNodeState.Copied
),
{
mouseDrop,
mouseDragEnter: (ev: go.InputEvent, obj: go.Node) => {
const node = obj.elt(0) as go.Shape;
node.stroke = '#ffc74c';
},
mouseDragLeave: (ev: go.InputEvent, obj: go.Node) => {
const node = obj.elt(0) as go.Shape;
node.stroke = '#1776D2';
},
selectionChanged,
},
$(
go.Shape,
new go.Binding('fill', '', (event: any) => {
if (event.state === GoJsNodeState.Copied) return '#ccc';
if (
event.state === GoJsNodeState.Palette ||
event.state === GoJsNodeState.Diagram
)
return 'white';
}),
new go.Binding('stroke', '', (event: any) => {
if (event.state === GoJsNodeState.Copied) return '#ccc';
if (
event.state === GoJsNodeState.Palette ||
event.state === GoJsNodeState.Diagram
)
return '#1776D2';
}),
{
strokeWidth: 1,
figure: 'RoundedRectangle',
alignment: go.Spot.Center,
}
),
$(
go.Panel,
{
stretch: go.GraphObject.Horizontal,
alignment: go.Spot.Center,
},
'Horizontal',
$(
go.TextBlock,
{
margin: new go.Margin(2, 10, 0, 5),
font: 'bold 10pt Barlow, sans-serif',
},
new go.Binding('text', 'title')
),
$(
'Button',
new go.Binding(
'visible',
'',
(event: any) => event.part.data.state === GoJsNodeState.Diagram
).ofObject(),
{
width: 22,
height: 22,
'ButtonBorder.stroke': null,
_buttonStrokeOver: null,
'ButtonBorder.fill': null,
_buttonFillOver: null,
click: deleteFromTemplate,
},
$(go.Picture, {
desiredSize: new go.Size(17, 17),
source: '/icons/circle-xmark-regular-black.png',
})
)
)
);
This one does not execute the callback (orange background):
const dropDocletType = $(
go.Node,
'Auto',
{
selectionChanged,
mouseDrop,
mouseDragEnter: (ev: go.InputEvent, obj: go.Node) => {
const node = obj.elt(0) as go.Shape;
node.strokeWidth = 1;
node.stroke = '#1776D2';
},
mouseDragLeave: (ev: go.InputEvent, obj: go.Node) => {
const node = obj.elt(0) as go.Shape;
node.strokeWidth = 0;
},
},
$(go.Shape, {
strokeWidth: 0,
figure: 'Ellipse',
fill: '#ffc74c',
}),
$(
go.TextBlock,
{
margin: new go.Margin(3, 0, 3, 0),
alignment: go.Spot.Center,
},
new go.Binding('text', 'text')
)
);