Diagram / Diagram DOM / Drawings / Shapes / Shape Events
In This Topic

    Shape Events

    In This Topic

    NOV Diagram shapes provide various events, which can be used to handle different scenarios. The following table lists the most commonly used shape events:

    Event Name Event Description
    MouseDown Raised when the user presses a mouse button while the mouse pointer is over the shape. Check the Click property of the event handler's argument to see if the event is a single or a double mouse click. See the sample code below this table.
    TransformChanged Raised when the shape transformation has changed.
    PageTransformChanged Raised when the shape transformation to page coordinates has changed.
    SizeChanged Raised when the shape Width or Height has changed.
    BeginPointChanged Raised when the BeginX or BeginY property has changed.
    EndPointChanged Raised when the EndX or EndY property has changed.
    GeometryChangedEvent Raised when any aspect of the shape geometry has changed.
    ControlsChangedEvent Raised when any aspect of the shape control points has changed.
    PortsChangedEvent Raised when any aspect of the shape ports has changed.
    BeginPointGlueChangedEvent Raised when any aspect of the shape begin point glue has changed.
    EndPointGlueChangedEvent Raised when any aspect of the shape end point glue has changed.
    MasterGlueChanged Raised when any aspect of the shape master glue has changed.
    ShapeCodeBehindChanged Raised when the code-behind of the shape has changed.
    InplaceEditingStarted Raised when the inplace editing of the shape has started.
    InplaceEditingCancelled Raised when the inplace editing of the shape has been cancelled or has failed.
    InplaceEditingCommitted Raised when the inplace editing of the shape has been committed, which is usually when the inplace text editor loses focus.
     Shape Mouse Down Example

    The following code demonstrates how to subscribe to the MouseDown event of a shape and how to detect double-clicks with the left mouse button:

    Shape Mouse Down Event
    Copy Code
    shape.MouseDown += OnShapeMouseDown;
    
    private static void OnShapeMouseDown(NMouseButtonEventArgs arg)
    {
        // Check if this is a double click with the left mouse button
        if (arg.Button == ENMouseButtons.Left && arg.Clicks == 2)
        {
            // Get the double-clicked shape
            NShape shape = arg.TargetNode as NShape;
            if (shape == null)
            {
                shape = arg.TargetNode.GetFirstAncestor<NShape>();
            }
    
            // Show a message box
            NMessageBox.Show("Shape double-clicked", "Double-click");
        }
    }
    

    If you are interested on the MouseDown event of the whole page and to get notified for each double click in the page, check the Page Events topic.

     Shape Text Edited Example

    To get notified when the user finishes editing the text of the shape via the inplace text editor, subscribe to the InplaceEditingCommitted. You can also subscribe to the InplaceEditingStarted event and store the initial text of the shape in a variable, which you can later compare to the shape text in the InplaceEditingCommitted event handler to see if the text of the shape has actually changed.

    Shape Inplace Editing Committed Event
    Copy Code
    shape.InplaceEditingCommitted += OnInplaceEditingCommitted;
    
    private static void OnShapeInplaceEditingCommitted(NShape shape)
    {
        string newShapeText = shape.Text;
    }
    
    See Also