Skip to content
Aleksandr edited this page May 22, 2019 · 1 revision

Widget events

An event is a message sent by an widget to signal the occurrence of an action. The action can be caused by user interaction, such as a button click, or it can result from some other program logic, such as changing a property’s value. The widget that raises the event is called the event sender. The event sender doesn't know which widget or method will receive (handle) the events it raises. The event is typically a member of the event sender; for example, the Arm event is a member of the Basic class.

Event handlers

Each event could have a corresponding callback-handler that is basically a function.

int push_button_cb( PtWidget_t *, void *, PtCallbackInfo_t *);

In the event handler, you perform the actions that are required when the event is raised, such as collecting user input after the user clicks a button. To receive notifications when the event occurs, your event handler method must subscribe to the event.

// You have somewhere:
PtWidget_t *ptwidget; // pointer to button widget

// constructing wrapper for Photon microGUI widget pointer
PhWidgets::Button button(ptwidget);

button.Activate += push_button_cb;
Clone this wiki locally