Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

Hi Friends,

I am using BREW 3.1.2 for developing my application. Several times i found out that my handle event function falls into an infinite loop whenever i try to handle a key event whether it is AVK_DOWN or AVK_UP or any other soft keys. For example, i have a menu control and when i press the down button or up button during debugging the handle event function falls into an infinite loop and in such a scenario when i disable the break point in the handle event function and try to execute, the menu bar goes down or up automatically. Can anyone please help me where am i going wrong?
Thanks in advance....... :)

I think u have not specifing in our handle event any of the three Key event listed below
EVT_KEY
EVT_KEY_PRESS
EVT_KEY_RELEASE
handle only one i.e EVT_KEY
switch(ecode)
{
case EVT_APP_START:
break;
case EVT_APP_STOP:
break;
case EVT_KEY:
//Here write u r menucontrol handle event
break;
}

I think u have not specifing in our handle event any of the three Key event listed below
EVT_KEY
EVT_KEY_PRESS
EVT_KEY_RELEASE
handle only one i.e EVT_KEY
switch(ecode)
{
case EVT_APP_START:
break;
case EVT_APP_STOP:
break;
case EVT_KEY:
//Here write u r menucontrol handle event
break;
}

Hi Kumaresh,
Thanks a lot for your quick reply.
I am handling all the key events within EVT_KEY only:
case EVT_KEY:
switch(wParam)
{
case AVK_SOFT2:
case AVK_CLR:
break;
case AVK_0:
break;
case AVK_1:
break;
.........
case AVK_SOFT1:
break;
case AVK_UP:
break;
case AVK_DOWN:
break;
case AVK_LEFT:
break;
case AVK_SELECT:
break;
case AVK_RIGHT:
break;
}
So let say i press the select button, then this event handler function is being called infinitely and the code under AVK_SELECT is executed repeatedly.
Thanks again....... :)

Hi Kumaresh,
Thanks a lot for your quick reply.
I am handling all the key events within EVT_KEY only:
case EVT_KEY:
switch(wParam)
{
case AVK_SOFT2:
case AVK_CLR:
break;
case AVK_0:
break;
case AVK_1:
break;
.........
case AVK_SOFT1:
break;
case AVK_UP:
break;
case AVK_DOWN:
break;
case AVK_LEFT:
break;
case AVK_SELECT:
break;
case AVK_RIGHT:
break;
}
So let say i press the select button, then this event handler function is being called infinitely and the code under AVK_SELECT is executed repeatedly.
Thanks again....... :)

case EVT_KEY:
//include ur code here
return(TRUE);
break;
try this it may help.

case EVT_KEY:
//include ur code here
return(TRUE);
break;
try this it may help.

Hi Manju,
Yes i have already taken care of that. Even i am returning TRUE its not working for me.

Hi Manju,
Yes i have already taken care of that. Even i am returning TRUE its not working for me.

if you spend too long handling an EVT_KEY event (e.g. because you have breakpointed it) then it will look like a long keypress to the emulator and you will get repeated events. Either return quickly from EVT_KEY and do the handling asynchronously, or handle EVT_KEY_PRESS/RELEASE instead.

if you spend too long handling an EVT_KEY event (e.g. because you have breakpointed it) then it will look like a long keypress to the emulator and you will get repeated events. Either return quickly from EVT_KEY and do the handling asynchronously, or handle EVT_KEY_PRESS/RELEASE instead.

Hi akshay,
You might find this hack applicable:
All key events that come for the first time have some dwParam value stored in them, but in case of repeated key events, you'll notice that dwParam is set to 64. If you look at this value and silently return from event handling code, your code wont be executed multiple times (but you'll still be receiving multiple key events that you can see in simulator till be you press another key on which no break point is set).
Example of code I'm saying:
// key press
case EVT_KEY:
if (dwParam == 64) return TRUE;
switch (wParam)
{
case AVK_CLR:
break;
case AVK_1: pApp->OnButton1_Click(); break;
...
...
...

You did not mention wheter you 'are' facing this problem in simulator or not (like in BenBlaukopf's post)
Hope this helps..

Hi akshay,
You might find this hack applicable:
All key events that come for the first time have some dwParam value stored in them, but in case of repeated key events, you'll notice that dwParam is set to 64. If you look at this value and silently return from event handling code, your code wont be executed multiple times (but you'll still be receiving multiple key events that you can see in simulator till be you press another key on which no break point is set).
Example of code I'm saying:
// key press
case EVT_KEY:
if (dwParam == 64) return TRUE;
switch (wParam)
{
case AVK_CLR:
break;
case AVK_1: pApp->OnButton1_Click(); break;
...
...
...

You did not mention wheter you 'are' facing this problem in simulator or not (like in BenBlaukopf's post)
Hope this helps..

Hi Taha,
Thanks a lot for the solution. I am having this problem in the emulator also.
When the control comes to the event handler for the second time during the debugging, the dwParam is set to 64 and i am returning TRUE and my code for the specific key event is only being executed once.The major benifit i can draw from this is the reduction in the overhead regarding the performance as earlier the same function within my key event was executed multiple times.
But can you please put some light on the significance of the dwParam value being set to 64 ? Is there any way we can restrict the event handler, so that it will not execute multiple times?
Hi Ben,
If we handle the EVT_KEY_PRESS or EVT_KEY_RELEASE, will this problem be gone?
Thanks a lot for your help...... :) :)

Hi Taha,
Thanks a lot for the solution. I am having this problem in the emulator also.
When the control comes to the event handler for the second time during the debugging, the dwParam is set to 64 and i am returning TRUE and my code for the specific key event is only being executed once.The major benifit i can draw from this is the reduction in the overhead regarding the performance as earlier the same function within my key event was executed multiple times.
But can you please put some light on the significance of the dwParam value being set to 64 ? Is there any way we can restrict the event handler, so that it will not execute multiple times?
Hi Ben,
If we handle the EVT_KEY_PRESS or EVT_KEY_RELEASE, will this problem be gone?
Thanks a lot for your help...... :) :)