Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Touch controller

Touch controllers are implementations of IController that can be used by their corresponding widgets to handle pointer events provided to the widget by Brew MP.

Touch-enabled widgets create a default touch controller, and pass all received touch events to the touch controller. This default touch controller can be overridden by calling IWidget_SetTouchController().

The following figure illustrates touch controller event handling.

The widget handles the events as follows:

  1. The user touches the screen and/or moves the finger (or stylus), which generates EVT_POINTER_DOWN, EVT_POINTER_MOVE, and EVT_POINTER_UP events.
  2. The event is passed to the widget.
  3. Widget checks if the event it received is a pointer event. If it has a valid touch controller, it will pass the event to the touch controller.
  4. The controller gets the relative coordinates of the hit from the event and queries the widget for the widget element under the hit, such as a scrollbar arrow.
  5. Based on the widget element being hit, the controller can then take different action like setting a property on the widget or performing a view model notification.

If an application needs to customize the behavior of the touch controller, it can do so by overriding the touch controller's handler. The application can also implement a new touch controller, set as the widget's touch controller by calling IWidget_SetTouchController().