Events - Guad/NativeUI GitHub Wiki
An event in C# is a way for a class to provide notifications to clients of that class when some interesting thing happens to an object. The most familiar use for events is in graphical user interfaces; typically, the classes that represent controls in the interface have events that are notified when the user does something to the control (for example, click a button).
NativeUI has 9 events in total: 6 for UIMenu, 1 for UIMenuItem, 1 for UIMenuListItem and 1 for UIMenuCheckboxItem.
Events basics
There are two ways to declare an event in C#. One is using a handler method and another one is using lambda expressions.
// First method.
myMenu.OnItemSelect += ItemSelectEventHandler;
public void ItemSelectEventHandler(UIMenu sender, UIMenuItem selectedItem, int index)
{
// Your logic goes here
}
And the second one is
// Second method.
myMenu.OnItemSelect += (sender, selectedItem, index) =>
{
// Your logic goes here
}
UIMenu Events
- OnIndexChange (UIMenu sender, int newindex)
- OnItemSelect (UIMenu sender, UIMenuItem selectedItem, int index)
- OnListChange (UIMenu sender, UIMenuListItem list, int newindex)
- OnCheckboxChange (UIMenu sender, UIMenuCheckboxItem item, bool Checked)
- OnMenuClose (UIMenu sender)
- OnMenuChange (UIMenu sender, UIMenu nextMenu, bool forward)
UIMenuItem Events
- Activated (UIMenu menu, UIMenuItem sender)
UIMenuCheckboxItem Events
- CheckboxEvent (UIMenuCheckboxItem sender, bool Checked)
UIMenuListItem Events
- OnListChanged (UIMenuListItem sender, int newindex)