Nevron Forum

Preventing Editing of a custom shape

https://www.nevron.com/Forum/Topic3882.aspx

By Ron Sawyer - Monday, July 26, 2010

I have a custom shape descended from NGroup. When I double click on it, an in-place editor pops up. (See attachment). I want to prevent this. I have tried setting the protection of both the shape and the rectangle (sample code of setting rectangle protection.) I have tried both true and false.

NAbilities protection = rect.Protection;

protection.InplaceEdit = true;



On a related note (I think) once the in-place editor has been invoked, the rectangle seems to separate from the shape when I drag it. (See second part of attachment) I want to prevent this as well. I have tried setting protection.ungroup.

[Serializable]

class TestClass : NGroup

{

      NRectangleShape rect;

      public TestClass()

      {

            // add a rectangle shape as base

            rect = new NRectangleShape(new NRectangleF(0, 0, 100, 300));

            rect.DestroyShapeElements(ShapeElementsMask.All);

            rect.Protection = new NAbilities(AbilitiesMask.Select | AbilitiesMask.InplaceEdit | AbilitiesMask.Copy);

            Shapes.AddChild(rect);

 

            // update the model bounds with the rectangle bounds

            UpdateModelBounds(rect.Transform.TransformBounds(rect.ModelBounds));

      }

}

By Nevron Support - Tuesday, July 27, 2010

Hi,

The correct way to set the protections of any shape or group is to get them first, then modify them and finally assign them back to the shape. For example:

 

NAbilities protection = rect.Protection;

protection.InplaceEdit = true;

rect.Protection = protection;

 

If you want to disable the nodes in the group to be moved you can apply the MoveX and MoveY protections or the Select protection on them.

By Ron Sawyer - Tuesday, July 27, 2010


rect.Protection = protection;


Ah, that's the part that I was missing!

Thanks, I'll give it a try.