Nevron Open Vision Documentation
Push Buttons

Push buttons are represented by the NButton class, which derives from NButtonBase. This is the most commonly used type of button. Typical examples are the Ok and Cancel buttons of a form or dialog as well as for other "actions" that the user may need to perform. The NButton class also contains a static method CreateImageAndText that can be used to quickly create a push button, which consists of an image and text next to it.

The WindowResult property of the NButton can be used to associate a window result with the window, which contains the button. This is commonly used when building dialogs, like demonstrated in the following example:

Window Result Example
Copy Code
void WindowResultTest()
    // create OK and Cancel buttons with respective results
    // when these buttons are clicke -> we need to close the window that contains them
    NButton okButton = new NButton("OK");
    okButton.WindowResult = ENWindowResult.OK;
    okButton.Click += new Nevron.Nov.Function<NEventArgs>(OnFormButtonClick);
    NButton cancelButton = new NButton("Cancel");
    cancelButton.WindowResult = ENWindowResult.Cancel;
    cancelButton.Click += new Nevron.Nov.Function<NEventArgs>(OnFormButtonClick);
    // arrange them in a horizontal stack
    NStackPanel stack = new NStackPanel();
    stack.Direction = ENHVDirection.LeftToRight;
    // show a modal window that contains the stack
    NTopLevelWindow wnd = new NTopLevelWindow();
    wnd.Content = stack;
    wnd.Closed += new Nevron.Nov.Function<NEventArgs>(OnWindowClosed);
    wnd.Modal = true;
void OnFormButtonClick(NEventArgs arg)
    // close the window that contains the button
    NTopLevelWindow wnd = (NTopLevelWindow)(((NWidget)arg.TargetNode).OwnerWindow);
void OnWindowClosed(NEventArgs arg)
    if (arg.EventPhase != ENEventPhase.AtTarget)
    // inspect the window result.
    // if result is None - then the user closed the window via the control box
    // if result is OK - then the user clicked the OK button.
    // if result is Cancel - then the user clicked the Cancel button.
    NTopLevelWindow wnd = (NTopLevelWindow)arg.TargetNode;
    Console.WriteLine("Window Closed with Result" + wnd.Result);


Send Feedback