Symbian3/SDK/Source/GUID-A51D3749-442A-54E8-8EB5-BF907694CD8C.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 13 Aug 2010 16:47:46 +0100
changeset 14 578be2adaf3e
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582

<?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-A51D3749-442A-54E8-8EB5-BF907694CD8C"><title>Processing Window-Group Events</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>The following examples demonstrate how to get window-group related event types, which are global within the window group and include: key events, modifier changed events, window focus lost and gained events and user defined 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>Key events</title> <p>To detect if a key event has occurred, use the <codeph>EEventKey</codeph>, <codeph>EEventKeyUp</codeph> or <codeph>EEventKeyDown</codeph> event types. </p> <p>You can get key event information by calling the <xref href="GUID-5D0B1595-1AC7-3C44-AC6B-0EFB5EABCF31.dita"><apiname>TWsEvent::Key()</apiname></xref> function. </p> <codeblock id="GUID-0FBDBD4E-29B6-5379-AD25-C6729BEC7FF2" xml:space="preserve">    // Key events - get the key code
    case EEventKey:
    case EEventKeyUp:
    case EEventKeyDown:
    {
    // Get the key event
    TKeyEvent&amp; keyEvent=*iWsEvent.Key();

    // Get the key code: values are defined in TKeyEvent
    TUint code = keyEvent.iCode;
    break;
    }
</codeblock> </section> <section><title>Modifier changed events</title> <p>To detect if a key modifier (the state of SHIFT, CTRL, etc. keys) changed event has occurred, use the <codeph>EEventModifiersChanged</codeph> event type. </p> <p>You can get key event information by calling the <xref href="GUID-5D0B1595-1AC7-3C44-AC6B-0EFB5EABCF31.dita"><apiname>TWsEvent::ModifiersChanged()</apiname></xref> function. </p> <codeblock id="GUID-70671D31-2EFE-5D8F-ADD4-C8F8591EE967" xml:space="preserve">    // A key modifier (e.g. SHIFT) changed
    case EEventModifiersChanged:
    {
    // Get the state of the modifier keys
    TKeyEvent&amp; keyEvent=*iWsEvent.ModifiersChanged();

    // Get the key modifiers: values are defined in TEventModifier
    TUint modifiers = keyEvent.iModifiers;
    break;
    }</codeblock> <p>This event type is not reported unless explicitly requested by a window. Use <xref href="GUID-5D0B1595-1AC7-3C44-AC6B-0EFB5EABCF31.dita"><apiname>RWindowTreeNode::EnableModifierChangedEvents()</apiname></xref> to request this event type. </p> </section> <section><title>Window focus lost and gained events</title> <p>To detect if the window focus has been lost or gained, use the <codeph>EEventFocusLost</codeph> and <codeph>EEventFocusGained</codeph> event types. </p> <p>You can get the handle to the window group whose focus has changed by calling <xref href="GUID-5D0B1595-1AC7-3C44-AC6B-0EFB5EABCF31.dita"><apiname>TWsEvent::Handle()</apiname></xref>. </p> <codeblock id="GUID-E4E6CE7E-D73C-58D6-8387-9912E1830EA5" xml:space="preserve">    // Window focus lost and gained events
    case EEventFocusLost:
    case EEventFocusGained:
    {
    // Get handle (typically a pointer) to the window group whose focus has changed
    TUint handle = iWsEvent.Handle();
    break;
    }</codeblock> </section> <section><title>User-defined event received from another window</title> <p>To detect if user-defined events have been received from another window, use <codeph>EEventUser</codeph>. </p> <p>You can get information about the event by calling <xref href="GUID-5D0B1595-1AC7-3C44-AC6B-0EFB5EABCF31.dita"><apiname>TWsEvent::EventData()</apiname></xref>. </p> <codeblock id="GUID-7059133B-1A1A-5EB1-9978-2FEEE9BB61B0" xml:space="preserve">
    // User-defined event received from another window
    case EEventUser:
    { 
    // Get a pointer to the event data
    TAny* data = iWsEvent.EventData();
    }</codeblock> </section> </conbody><related-links><link href="GUID-B58D3727-6E05-51C8-8EC2-52768A136BD5.dita"><linktext>Window Server Client-Side Events
                Overview</linktext> </link> <link href="GUID-E1E11C95-3400-548B-AEEE-577DA8FB9ECB.dita"><linktext>Processing Window Events</linktext> </link> <link href="GUID-930A3ABD-84FB-5D76-938C-79383273DAE6.dita"><linktext>Processing System Events</linktext> </link> </related-links></concept>