Working with PostEvent | developer.brewmp.com Working with PostEvent | developer.brewmp.com

Developer

Working with PostEvent

Forums:

hi,
Iam new to BREW. I wrote an application in which let us say i have two applets app1.c and another app2.c

Iam posting an even from app1.c to app2.c using ISHELL_PostEvent()

This ISHELL_PostEvent is returning false if I send my evt_code as any System events like EVT_APP_START or key events like EVT_KEY. It is returning TRUE only if I send EVT_USER.

Can any one tel me what might be the reason??

Second thing is like after posting the event with event code as EVT_USER, when I debug the code the control is going to app2.c and in the app2_HandleEvent, in EVT_USER code i wrote a code to display some string "HELLO WORLD". But Iam unable to display the string??

Can any one tel me how to communicate between the applets using ISHELL_PostEvent() and also I have to work on key events??

Thanks in advance.

Simple you can't send system Events in BREW.

Simple you can't send system Events in BREW.

Hi Brewin,
Thanks for the info. But can u tel me what are user events?? I mean what kind of events comes under user events??? Can a key press event comes under user event.
Iam writing an application in which i post the key events to the other applets.
Can u tel me how to do it??
Thanks a lot.

Hi Brewin,
Thanks for the info. But can u tel me what are user events?? I mean what kind of events comes under user events??? Can a key press event comes under user event.
Iam writing an application in which i post the key events to the other applets.
Can u tel me how to do it??
Thanks a lot.

Define your EVT_SPECIAL greater than EVT_USER.
Sent the Event as EVT_SPECIAL with proper wParam.
In your App Event Handler,
switch(ecode)
{
case EVT_SPECIAL:
do your Stuff.....
return TRUE;

Define your EVT_SPECIAL greater than EVT_USER.
Sent the Event as EVT_SPECIAL with proper wParam.
In your App Event Handler,
switch(ecode)
{
case EVT_SPECIAL:
do your Stuff.....
return TRUE;

Hi Brewin,
Iam totally new to BREW and Iam unable to understand your point.
I have the following doubts.
1. What typ of events comes under EVT_USER??
2. Can I post a key press event using the event code EVT_USER??
My application is is to receive different key press events from the user in one applet and post the events to another applet in which i will handle each key press events according to the application needs.
U said some thing called EVT_SPECIAL to be greater than EVT_USER. What is that event code and also how to use it??
And in some documents some people mentioned about EVT_USER+100 can u tel me what does that mean??

Hi Brewin,
Iam totally new to BREW and Iam unable to understand your point.
I have the following doubts.
1. What typ of events comes under EVT_USER??
2. Can I post a key press event using the event code EVT_USER??
My application is is to receive different key press events from the user in one applet and post the events to another applet in which i will handle each key press events according to the application needs.
U said some thing called EVT_SPECIAL to be greater than EVT_USER. What is that event code and also how to use it??
And in some documents some people mentioned about EVT_USER+100 can u tel me what does that mean??

Check the AEE header file for AEE Events.
The below line is defined in AEE.h file under AEE Events...
#define EVT_USER 0x7000 // Start of App/User defined Events. Private to apps...
So the Events below 0x7000 are system or OEM events which you can't send.
i.e 0x0000 to 0x6FFF are BREW SYSTEM or OEM Events.
Form 0x7000 to 0xFFFF, you can define any value as USER Events.....
USER Events are defined and used by developers as per their requirements...
The Below code send an AVK_1 key with AEE EVENT as EVT_USER....
ISHELL_SendEvent(pMe->a.m_pIShell,AEECLSID_YOURAPP,EVT_USER,AVK_1,1);
or
ISHELL_PostEvent(pMe->a.m_pIShell,AEECLSID_YOURAPP,EVT_USER,AVK_1,1);
The above code will post the EVT_USER AEE Event to the respected class ID
To Handle this event, just add the EVT_USER case statement above the EVT_KEY case in your applet handle event method....
case EVT_USER:
case EVT_KEY:
return TRUE;
eCode are AEE EVENTS, You can send any normal wParam i.e AVK_x with the API call.
you can define your own EVT_USER as EVT_ENTERNAME > 0x7000 as EVT_USER is defined with 0x7000 and below that are used by BREW and OEM's.
You can even post SYSTEM EVENTS, but in an unusual manner...thing b4 use this..
post your SYSTEM EVENT as
ISHELL_SendEvent(pMe->a.m_pIShell,AEECLSID_YOURAPP,EVT_USER+AEE_EVENT,wParam,dwParam);
in your App Event handler check the ecode > EVT_USER ==> your posted ecode
then subtract EVT_USER from ecode so that you actually setting the ecode to SYSTEM AEE EVENT..
if(ecode>EVT_USER) ecode -= EVT_USER;
Note: The posted Event will effect only your code, not the BREW -- As far as BREW is concerned EVT_USER + AEE_EVENT is just an EVT_USER event.

Check the AEE header file for AEE Events.
The below line is defined in AEE.h file under AEE Events...
#define EVT_USER 0x7000 // Start of App/User defined Events. Private to apps...
So the Events below 0x7000 are system or OEM events which you can't send.
i.e 0x0000 to 0x6FFF are BREW SYSTEM or OEM Events.
Form 0x7000 to 0xFFFF, you can define any value as USER Events.....
USER Events are defined and used by developers as per their requirements...
The Below code send an AVK_1 key with AEE EVENT as EVT_USER....
ISHELL_SendEvent(pMe->a.m_pIShell,AEECLSID_YOURAPP,EVT_USER,AVK_1,1);
or
ISHELL_PostEvent(pMe->a.m_pIShell,AEECLSID_YOURAPP,EVT_USER,AVK_1,1);
The above code will post the EVT_USER AEE Event to the respected class ID
To Handle this event, just add the EVT_USER case statement above the EVT_KEY case in your applet handle event method....
case EVT_USER:
case EVT_KEY:
return TRUE;
eCode are AEE EVENTS, You can send any normal wParam i.e AVK_x with the API call.
you can define your own EVT_USER as EVT_ENTERNAME > 0x7000 as EVT_USER is defined with 0x7000 and below that are used by BREW and OEM's.
You can even post SYSTEM EVENTS, but in an unusual manner...thing b4 use this..
post your SYSTEM EVENT as
ISHELL_SendEvent(pMe->a.m_pIShell,AEECLSID_YOURAPP,EVT_USER+AEE_EVENT,wParam,dwParam);
in your App Event handler check the ecode > EVT_USER ==> your posted ecode
then subtract EVT_USER from ecode so that you actually setting the ecode to SYSTEM AEE EVENT..
if(ecode>EVT_USER) ecode -= EVT_USER;
Note: The posted Event will effect only your code, not the BREW -- As far as BREW is concerned EVT_USER + AEE_EVENT is just an EVT_USER event.

Hi Brewin,
Thanks a lot for the information.
I have one more doubt.
Can we post the events from a background application using ISHELL_PostEvent()??
Thanks

Hi Brewin,
Thanks a lot for the information.
I have one more doubt.
Can we post the events from a background application using ISHELL_PostEvent()??
Thanks

Yes you can.

Yes you can.

Hi Brewin,
Sorry to bother u again.
Actually in my applet i will recieve virtual key codes for each key press and I have to map their virtual key codes to BREW's corresponding key codes and simulate the key codes accordingly. If u have any idea how to simulate virtual key codes can u please share it with me. Also if there is any example code please post it.
Thanks

Hi Brewin,
Sorry to bother u again.
Actually in my applet i will recieve virtual key codes for each key press and I have to map their virtual key codes to BREW's corresponding key codes and simulate the key codes accordingly. If u have any idea how to simulate virtual key codes can u please share it with me. Also if there is any example code please post it.
Thanks

wParam holds the Virtual key code.
In your Event handler, You will get this Virtual key code in wParam variable which is 16bit Integer.
AVK type are nothing but virtual key codes defined by BREW.
AVK_0, // by pressing 0 on the mobile, wParam is fill wth the value 57377
AVK_1, // 57378
so on....
These are defined in aeevcodes.h file. where AVKtype is an enum structure.
check it.

wParam holds the Virtual key code.
In your Event handler, You will get this Virtual key code in wParam variable which is 16bit Integer.
AVK type are nothing but virtual key codes defined by BREW.
AVK_0, // by pressing 0 on the mobile, wParam is fill wth the value 57377
AVK_1, // 57378
so on....
These are defined in aeevcodes.h file. where AVKtype is an enum structure.
check it.

hi,
actually I want to simulate the keypress.
In Symbian to simulate a keypress we have something like
TWsEvent event;
RWsSession wsSession=CCoeEnv::Static()->WsSession();
TInt id = wsSession.GetFocusWindowGroup();
event.SetType(EEventKey);
event.SetTimeNow();
event.Key()->iCode = EKeyUpArrow;
event.Key()->iModifiers = 0;
event.Key()->iRepeats = 0;
event.Key()->iScanCode = EStdKeyUpArrow;
wsSession.SendEventToWindowGroup( id, event );
wsSession.Flush();
The above code is to simulate a key press in Symbian. Like that is there any way to simulate a key press in BREW???
What I want to say is if I can simulate a keypress then I need not press that particular key in simulator. By simulating a key press and adding that to the kernel api like in Symbian we can call the function myfirstapp_HandleEvent() with out actually pressing the key on the simulator.

hi,
actually I want to simulate the keypress.
In Symbian to simulate a keypress we have something like
TWsEvent event;
RWsSession wsSession=CCoeEnv::Static()->WsSession();
TInt id = wsSession.GetFocusWindowGroup();
event.SetType(EEventKey);
event.SetTimeNow();
event.Key()->iCode = EKeyUpArrow;
event.Key()->iModifiers = 0;
event.Key()->iRepeats = 0;
event.Key()->iScanCode = EStdKeyUpArrow;
wsSession.SendEventToWindowGroup( id, event );
wsSession.Flush();
The above code is to simulate a key press in Symbian. Like that is there any way to simulate a key press in BREW???
What I want to say is if I can simulate a keypress then I need not press that particular key in simulator. By simulating a key press and adding that to the kernel api like in Symbian we can call the function myfirstapp_HandleEvent() with out actually pressing the key on the simulator.

For this you can use Grinder.

For this you can use Grinder.

Hi Brewin,
can u give me sample code for using grinder.
When I browse for grinder it is saying that to open a grinder we have to right click on the simulator display, but for me if i right click on the simulator iam able to see only one option i.e toggle backlight. Can u please tel me how to simulate the key press using grinder??
and also u said in your previously reply that it is possible to post events from background applications. can u give sample code how to post the events from background application to focus applications???
Actully my application runs in the background and i have to simulate the key press events and post the events to the focus applications.

Hi Brewin,
can u give me sample code for using grinder.
When I browse for grinder it is saying that to open a grinder we have to right click on the simulator display, but for me if i right click on the simulator iam able to see only one option i.e toggle backlight. Can u please tel me how to simulate the key press using grinder??
and also u said in your previously reply that it is possible to post events from background applications. can u give sample code how to post the events from background application to focus applications???
Actully my application runs in the background and i have to simulate the key press events and post the events to the focus applications.