Processing Window Events

The following examples demonstrate how to process window-related event types, which are events local to specific windows and include pointer events.

Variant: ScreenPlay and non-ScreenPlay. Target audience: Application developers.

Pointer events

To detect if a pointer event has been issued, use the EEventPointerEnter, EEventPointerExit, EEventPointer and EEventDragDrop event types.

You can request information about the pointer event type by calling the TWsEvent::Pointer() function.

    // Pointer events
    case EEventPointer:
    case EEventDragDrop:
    {
    // Gets the pointer position
    TPointerEvent& pointerEvent = *iWsEvent.Pointer();
    TPoint point = pointerEvent.iPosition;
    break;
    }

Pointer events are ready to retrieve from a buffer

To detect whether pointer events are ready to retrieve from a buffer, use the EEventPointerBufferReady event type.

The RWindowBase::EnablePointerMoveBuffer() function instructs the Window Server to begin putting pointer events into the pointer move buffer.

You can get the buffer containing the stored pointer events by calling RWindowBase::RetrievePointerMoveBuffer().

    // Pointer events are ready to retrieve from a buffer
    case EEventPointerBufferReady:
    {
    const TInt KPointerMoveBufferSize = 20;

    // Gets the window
    RWindow* window = (RWindow*)(iWsEvent.Handle());

    // Set up an array of TPoints into which to read the buffer
    TPoint pnts[KPointerMoveBufferSize];
    TPtr8 ptr((TUint8 *)&pnts;,sizeof(pnts));
    TInt numPts = window -> RetrievePointerMoveBuffer(ptr);
    break;
    }

Note that the way to map the handle to a window depends on the environment that you are working in, usually this will be the UI Control Framework which will have to do this mapping a different way.