Nevron Open Vision Documentation
Diagram / Diagram DOM / Drawings / Pages / Page Events
In This Topic
    Page Events
    In This Topic

    NOV Diagram pages provide a number of events, which can be used to get notified when a specific event occurs in the drawing page.

     Shape Inserted and Removed Events

    Diagram shapes are added to the Items property of the page. To get notified when a shape has been added or removed from a page, subscribe to the ChildInserted and ChildRemoved events of the page's Items collection as shown below:

    Shape Inserted and Removed Events
    Copy Code
    NPage page = drawingView.ActivePage;
    page.Items.ChildInserted += OnPageChildInserted;
    page.Items.ChildRemoved += OnPageChildRemoved;
    
    private void OnPageChildInserted(NInsertChildEventArgs arg)
    {
        NShape shape = arg.InsertedNode as NShape;
        if (shape != null)
        {
            NMessageBox.Show("Shape Name: " + shape.Name, "Shape Inserted");
        }
    }
    private void OnPageChildRemoved(NRemoveChildEventArgs arg)
    {
        NShape shape = arg.RemovedNode as NShape;
        if (shape != null)
        {
            NMessageBox.Show("Shape Name: " + shape.Name, "Shape Removed");
        }
    }
    
     User Input Events

    The page also provides many user input events, which are raised when the user moves or clicks with the mouse or when he presses keys from the keyboard. The following code example demonstrates how to handle page double-clicks with the left mouse button:

    Page Mouse Down Event
    Copy Code
    page.MouseDown += OnPageMouseDown;
    
    private static void OnPageMouseDown(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>();
            }
    
            if (shape != null)
            {
                // Show a message box
                NMessageBox.Show("Shape double clicked", "Double Click");
            }
        }
    }
    

    If you are interested on the MouseDown event of individual shapes, check the Shape Events topic.

    See Also