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.

    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.

    See Also