Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



How to process window-related events

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


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

[Top]


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.