|
|
Classification: |
C++ |
Category: |
Window Server |
Created: |
05/09/2002 |
Modified: |
05/10/2002 |
Number: |
FAQ-0792 |
Platform: |
Symbian OS v6.0, Symbian OS v6.1 |
|
Question: I want to simulate window server events, such as pointer presses, being delivered to another window. How can I do this?
Answer: You can use a method SendEventToWindowGroup(TInt, const TWsEvent&) of RWsSession as follows. Note there is nothing to stop you using this approach to send events to your own window group if, say, you are
writing a test harness for your UI. Here is some code that will send a "pointer down" event to position (20, 20) in a window
group called "TestApp"
RWsSession& wsSession=iCoeEnv->WsSession(); _LIT(KWgName, "TestApp"); TInt wgId=wsSession.FindWindowGroupIdentifier(0, KWgName); if (wgId<=0){ // notify error User::Leave(KErrNotFound); }TWsEvent wsEvent; wsEvent.SetType(EEventPointer); // type is a member of TEventCode enum TPointerEvent& pointerEvent=*wsEvent.Pointer(); pointerEvent.iType=TPointerEvent::EButton1Down; pointerEvent.iModifiers=0; pointerEvent.iPosition=TPoint(20,20); pointerEvent.iParentPosition=TPoint(0,0); // don't try to use this in handling event // don't try to set event data separately through EventData() as this overwrites pointerEvent data! User::LeaveIfError(wsSession.SendEventToWindowGroup(wgId,wsEvent));
|
|
|