Is there a way to tell if node/part is in Palette or in diagram

I want to hide selection adornment if in palette and for that i have binded visible property to a function in which we can get that part, but is there any property of that part which can tell the difference that it is being accessed inside the palette or main diagram panel?

function adornVisible(adorn){
       //a way to tell if it is being accessed in palette or not
}

selectionAdornmentTemplate:  // custom selection adornment
        $(go.Adornment, "Spot",      
        $(go.Placeholder),
        $(go.Shape,"Triangle"
          {
            alignment: go.Spot.Center,
            alignmentFocus: go.Spot.Left,
            stroke: "pink"
          }),
          new go.Binding("visible", "", adornVisible).ofObject()
        )

adorn.diagram instanceof go.Palette

Thanks @walter it worked.

Hi @walter,

This binding is being called several times, only for one click the adornVisible functions get called about 8-10 times and some times in starting it doesn’t have all the properties like location and actualbounds is there any other method also which can provide all the properties of the adornment at once only.
Any other selection event which will be called once only with all the properties.

When a Binding’s source property name is the empty string, it is likely to be evaluated much more often than a Binding that has a specific source property.

This seems to reduce the number of calls, but not down to once:

new go.Binding("visible", "diagram", function(d) { return !(d instanceof go.Palette); }).ofObject()

If that really matters to you, it might be easier to just set Part.selectionAdorned to false on each Part that is in your Palette.

For some other scenario’s whenever it is being drawn on the canvas i need some other properties of the adornment also (not just the diagram).

Binding conversion functions can have arbitrary state dependencies. But they should be fast, stable, and not modify any state.

There is no way to declare that a Binding has more than one source property dependency, other than to use the empty string as the source property name. That means it will get evaluated more often than you might think it is necessary.

Some times i am not getting some properties of the actual bounds on visible event.
perfect condition is like this for adorn.actualBounds

  1. $: 330.15000000000003
  2. G: 895
  3. H: 52.80827490204163
  4. aa: 251.22
  5. u: false

But mostly i am getting this .

  1. $: 330.15000000000003
  2. G: 0
  3. H: 0
  4. aa: 251.22
  5. u: false

Is there any other event for visibility of the adornment where I can get all the properties of the adornment.actualBounds.

The measurement and then the arrangement of GraphObjects in Panels must happen after the evaluation of bindings in order for bindings to be able to affect how the objects are measured and arranged.

Since you have also sent us email, we’ll continue the conversation by email.