Week 23 contribution of PDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License
"Eclipse Public License v1.0" which accompanies this distribution,
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
Nokia Corporation - initial contribution.
Contributors:
-->
<!DOCTYPE concept
PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept xml:lang="en" id="GUID-E1E11C95-3400-548B-AEEE-577DA8FB9ECB"><title>Processing Window Events</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>The following examples demonstrate how to process window-related event types, which are events local to specific windows and include pointer events. </p> <p> <b>Variant</b>: <xref href="GUID-D93978BE-11A3-5CE3-B110-1DEAA5AD566C.dita">ScreenPlay</xref> and <xref href="GUID-F64E6551-670E-5E12-8103-DE504D3EC94F.dita">non-ScreenPlay</xref>. <b>Target audience</b>: Application developers. </p> <section><title>Pointer events</title> <p>To detect if a pointer event has been issued, use the <codeph>EEventPointerEnter</codeph>, <codeph>EEventPointerExit</codeph>, <codeph>EEventPointer</codeph> and <codeph>EEventDragDrop</codeph> event types. </p> <p>You can request information about the pointer event type by calling the <xref href="GUID-5D0B1595-1AC7-3C44-AC6B-0EFB5EABCF31.dita"><apiname>TWsEvent::Pointer()</apiname></xref> function. </p> <codeblock id="GUID-90CD8C29-ED2D-5CF6-9EDF-8F60ACA7B2D3" xml:space="preserve"> // Pointer events
case EEventPointer:
case EEventDragDrop:
{
// Gets the pointer position
TPointerEvent& pointerEvent = *iWsEvent.Pointer();
TPoint point = pointerEvent.iPosition;
break;
}</codeblock> </section> <section><title>Pointer events are ready to retrieve from a buffer</title> <p>To detect whether pointer events are ready to retrieve from a buffer, use the <codeph>EEventPointerBufferReady</codeph> event type. </p> <p>The <xref href="GUID-5D0B1595-1AC7-3C44-AC6B-0EFB5EABCF31.dita"><apiname>RWindowBase::EnablePointerMoveBuffer()</apiname></xref> function instructs the Window Server to begin putting pointer events into the pointer move buffer. </p> <p>You can get the buffer containing the stored pointer events by calling <xref href="GUID-5D0B1595-1AC7-3C44-AC6B-0EFB5EABCF31.dita"><apiname>RWindowBase::RetrievePointerMoveBuffer()</apiname></xref>. </p> <codeblock id="GUID-A878A55B-2987-5331-BC2D-88330F7907A6" xml:space="preserve"> // 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;
}
</codeblock> <p>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. </p> </section> </conbody><related-links><link href="GUID-CD550DE7-D013-527B-BADE-5CB122C352C8.dita"><linktext>Pointer Handling</linktext> </link> <link href="GUID-A12A66ED-2C8F-5CE6-8F3E-332B045A35B4.dita"><linktext>Advanced Pointers</linktext> </link> <link href="GUID-B830A1F7-9220-5879-80BE-C494A4CD155B.dita"><linktext>General Events</linktext> </link> <link href="GUID-A51D3749-442A-54E8-8EB5-BF907694CD8C.dita"><linktext>Processing Window-Group
Events</linktext> </link> </related-links></concept>