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

Developer

resources

Touch controller customization

Before creating default touch controllers, the widget that is being created should try to create an instance of the OEM touch controller. If the application is unable to create an OEM touch controller, then it creates a default touch controller.

Manufacturers can replace default touch controllers by implementing a class for a pre-defined OEM ClassID. This will override the platform touch controllers. OEM ClassIDs are provided with the widgettc modules.

You can also create a custom touch controller by implementing custom controllers and set them on individual widgets. Another way to override a controller on a widget is by explicitly setting it using the PROPEX_TOUCH_CONTROLLER property. This way, no ClassID needs to be implemented and a specific controller can be set on a widget. To implement the actual controller, you must implement the IController interface.

In the controller event handler, the controller will typically get EVT_POINTER events. But apart from pointer events, a controller may also get some property events. One typical example is EVT_WDG_SETPROPERTY with PROP_VIEWMODEL. A widget will provide its view model to the controller whenever there is one. A controller may ignore this property if it is not interested in the view model.

On getting pointer events, a controller typically calls IWidget_FindElement() based on the pointer coordinates, and then it uses this information to take further action. FindElement returns the widget element being hit. To extend the behavior of the existing touch controller instead of writing a custom touch controller, you can get the existing touch controller of the widget using PROPEX_TOUCH_CONTROLLER and set a handler on the controller using IController_SetHandler()

Replacing the default Touch Controller

The application calls IWidget_SetTouchController() to replace the default touch controller for a widget, as shown in the following example:

IController *pitc = 0; 
nErr = ISHELL_CreateInstance(piShell, AEECLSID_CButtonTC, (void **)&pitc); 
if (AEE_SUCCESS == nErr) { 
   nErr = IWidget_SetTouchController(*ppo, pitc); 
}

Replacing the handler for a Touch Controller

The application can call IController_SetHandler() to replace the event handler for a Touch Controller, as shown below. The overriding event handler must call the event handler that it replaced. The previous handler is returned by IController_SetHandler() in the pDesc parameter.

This new event handler will be called by the Touch Controller when handling events.

nErr = IController_SetHandler(pi, pDesc); 
if (AEE_SUCCESS != nErr) { 
   //code to handle error goes here 
}