Resources | Resources |



Customizing touch event handling

You can customize touch event handling to add new or different touchscreen capabilities. For example, you could replace the Touch Controller to add flick support to a text widget, allowing the user to flick through the text. You could also replace the default Touch Observer to change or add touch capabilities, such as changing the way a double-tap is determined, or in conjunction with adding a handler to a touch controller.

Replacing the default Touch Observer

To replace the Touch Observer, an application would first need to create a new Touch Observer, then call IWidget_SetPropertyEx() on the root container to set the Touch Observer, as follows:

nErr = ISHELL_CreateInstance(piShell, AEECLSID_CTouchObserver,
            (void **)& piTO))

if (AEE_SUCCESS == nErr) {
   nErr = IWidget_SetPropertyEx(piwRoot, PROPEX_TOUCHOBSERVER, sizeof(piTO),
            (void*) piTO);

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);

Adding a handler to a Touch Controller

The application can call IController_SetHandler() to add an event handler to a Touch Controller, as shown below. The handler is a second event handler that the Touch Controller will call when handling events.

// Initialize the HandlerDesc data structure
HANDLERDESC_Init(pDesc, CustomHandler, pMe, NULL); 

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