Resources | Resources |




The widget controller handles user interaction, such as key or pointer events.

The controller is used to interpret certain events passed to widgets. It updates the widget's view and model based on these events.

IController is the interface for a controller in the Model-View-Controller triad. This part of MVC is often combined with the view part of the widget. Many of the widgets that Brew MP UI Widgets offers combine the view and the controller in a single object, but keep the model as a separate object. The fact that the view and the controller are combined in these cases is because these two portions of the MVC triad are simplistic, intertwined, and specific to one another and, therefore, unlikely that the controller could be reusable by another view. 

A common exception to this is the touch controller, which is always separate regardless of the widget. The touch controller is maintained as a separate object for these reasons:

  • Not every embedded device has touch support.
  • Developers may have specific requirements for touch behavior that necessitate supplying a custom, more specialized, controller.

Using a controller

An application can use a controller as follows:

  1. Create an instance of a controller by calling ISHELL_CreateInstance() with the ClassID of the controller.
  2. To manage instances of a controller, call IController_AddRef() and IController_Release().
  3. Call IController_SetWidget() to associate a widget with the controller.
  4. Forward any events that need to be handled by the controller to the registered handler by calling IController_HandleEvent().