Nevron Open Vision Documentation
Buttons Overview

All buttons in NOV UI inherit from the abstract NButtonBase class which is a content element that provides support for a click event. The fact that the button is a content element means that it can contain every widget.

In most cases you will create buttons by calling the initializing constructor that accepts an object parameter. The passed object is converted to a widget via the NWidget.FromObject static method. You can also create buttons by calling their default constructor and then setting their Content as demonstrated in the following code example:

Creating Buttons
Copy Code
// shortcut for creating a button with a label (internally uses NWidget.FromObject).
NButton button1 = new NButton("Hello NOV");
// shortcut equivalent
NButton button2 = new NButton();
button2.Content = new NLabel("Hello NOV");

Clicking Buttons

All types of buttons raise a Click event. Depending on the button ClickMode, the click event is raised either when the button changes it's state from normal to pressed (ClickMode = Press), or when it changes its state from pressed or normal (i.e. is released - ClickMode = Release).

A button can be pressed and subsequently released in two ways:

  1. Keyboard - when the user presses the Space keyboard button.
  2. Mouse - when the user presses the Left mouse button over the button.

The example below demonstrates how to create a button and handle its click event:

Handling the Button Click Event
Copy Code
NButton button = new NButton("Click me");
button.Click += new new Function<NEventArgs>(OnButtonClick);

private void OnButtonClick(NEventArgs arg1)
{
    // Get the clicked button
    NButton button = (NButton)arg1.CurrentTargetNode;
}

Buttons expose a DoClick public method that can be used to generate a Click event for the button. This is useful when you need to simulate a click event for a button as if the user has clicked it using the mouse.

Buttons Class Hierarchy

The image below shows the button base descendants:

 

Send Feedback