problem overridding the default event handler | developer.brewmp.com problem overridding the default event handler | developer.brewmp.com

Developer

problem overridding the default event handler

I have created a menu UI in which the main menu form loads two other forms based on the selection.
I have defined two custom event handlers for the two forms and hooked them.
it is all working fine however the moment i am defining any key on the main event handler which i have already defined in my custom handler then the main code is also getting called along with the custom one. when i click the left soft key it goes back to the main form as intended but there also it triggers the left soft key.

How do i solve this any help?

my code

Main EVEnt HANDLER
static boolean helloformapp_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
helloformapp *me = (helloformapp *)pi;
IWidget *piw = NULL;
int index ;
(void)dwParam;

IROOTFORM_HandleEvent(me->piRootForm, eCode, wParam, dwParam);

switch (eCode) {
// App is told it is starting up
case EVT_APP_START:
// Add your code here...
return(TRUE);

// App is told it is exiting
case EVT_APP_STOP:
// Add your code here...
return(TRUE);

// App is being suspended
case EVT_APP_SUSPEND:
// Add your code here...
return(TRUE);

// App is being resumed
case EVT_APP_RESUME:
// Add your code here...
return(TRUE);

// An SMS message has arrived for this app. Message is in the dwParam above as (char *)
// sender simply uses this format "//BREW:ClassId:Message", example //BREW:0x00000001:Hello World
case EVT_APP_MESSAGE:
// Add your code here...
return(TRUE);

// A key was pressed. Look at the wParam above to see which key was pressed. The key
// codes are in AEEVCodes.h. Example "AVK_1" means that the "1" key was pressed.
case EVT_KEY:
switch (wParam) {
// UP
case AVK_UP:

return TRUE;

// DOWN
case AVK_DOWN:

return TRUE;

// LEFT
case AVK_LEFT:
return TRUE;

// RIGHT
case AVK_RIGHT:
return TRUE;

// SELECT
case AVK_SELECT:

IWIDGET_GetProperty(me->pListWidget,PROP_FOCUSINDEX,&index);
switch(index)
{
case 0:
//(void)IROOTFORM_PopForm(me->piRootForm);
//RELEASEIF(me->piForm);
helloformapp_CreateForm2(me);

return TRUE ;
case 1:
//(void)IROOTFORM_PopForm(me->piRootForm);
// RELEASEIF(me->piForm);
helloformapp_CreateForm3(me);

return TRUE;
}

return TRUE;

// CLEAR
case AVK_CLR:
// (void)IROOTFORM_PushForm(me->piRootForm,me->piForm);
return TRUE;

// SOFTKEY 1
case AVK_SOFT1:

return TRUE;

// SOFTKEY 2
case AVK_SOFT2:
(void)IROOTFORM_PopForm(me->piRootForm);//THIS IS GETTING CALLED AFTER I PRESS THE FORM2 EVENTHANDLER'S SOFTKEY .
//(void)ISHELL_CloseApplet(me->pIShell, FALSE);
return TRUE;

default:
break;
}

return (TRUE);

// If nothing fits up to this point then we'll just break out
default:
break;
}

return FALSE;

my custom event handler
static boolean helloformapp_createform2_HandleEvent(helloformapp* me, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{

if(eCode==EVT_KEY)
{
if(wParam == AVK_SOFT2)
{

(void)IROOTFORM_RemoveForm(me->piRootForm,me->piForm2);
return TRUE;

}

}

return HANDLERDESC_Call( &me->handlerdescform2, eCode, wParam, dwParam );
}

AnySuggestions Welcome.

problem solved dont bother

problem solved dont bother

:(
no solution
mine didnt work actually
The main problem is why is the main event handler handling the events which are
being handled by the custom event handler?

:(
no solution
mine didnt work actually
The main problem is why is the main event handler handling the events which are
being handled by the custom event handler?

Hi,
cyankhan wrote:
IROOTFORM_HandleEvent(me->piRootForm, eCode, wParam, dwParam);
just try with performing the IROOTFORM_HandleEvent(..) in a if test and return TRUE from it,
if(IROOTFORM_HandleEvent(...))
{
return TRUE;

Hi,
cyankhan wrote:
IROOTFORM_HandleEvent(me->piRootForm, eCode, wParam, dwParam);
just try with performing the IROOTFORM_HandleEvent(..) in a if test and return TRUE from it,
if(IROOTFORM_HandleEvent(...))
{
return TRUE;

Prayag wrote:Hi,
just try with performing the IROOTFORM_HandleEvent(..) in a if test and return TRUE from it,
if(IROOTFORM_HandleEvent(...))
{
return TRUE;

Thanks for your reply but it didnt work
It only disabled the AVK_SELECT of the main handler.

Prayag wrote:Hi,
just try with performing the IROOTFORM_HandleEvent(..) in a if test and return TRUE from it,
if(IROOTFORM_HandleEvent(...))
{
return TRUE;

Thanks for your reply but it didnt work
It only disabled the AVK_SELECT of the main handler.

When you call IROOTFORM_HandleEvent() in your main event handler with form 2 displayed, that will call helloformapp_createform2_HandleEvent(). Whatever your form's event handler returns will be returned by IROOTFORM_HandleEvent(), but you are not checking the return value of IROOTFORM_HandleEvent(). If it returns TRUE that means that one of the widgets has handled the event, and the main event handler shouldn't do anything with the event.
Also, this is not the best way to handle menu selection. Add a focus listener to the list widget with IWIDGET_SetFocusListener() and listen for EVT_MDL_FOCUS_SELECT. The dwParam of the ModelEvent will be the index of the selected item.
-Erik

When you call IROOTFORM_HandleEvent() in your main event handler with form 2 displayed, that will call helloformapp_createform2_HandleEvent(). Whatever your form's event handler returns will be returned by IROOTFORM_HandleEvent(), but you are not checking the return value of IROOTFORM_HandleEvent(). If it returns TRUE that means that one of the widgets has handled the event, and the main event handler shouldn't do anything with the event.
Also, this is not the best way to handle menu selection. Add a focus listener to the list widget with IWIDGET_SetFocusListener() and listen for EVT_MDL_FOCUS_SELECT. The dwParam of the ModelEvent will be the index of the selected item.
-Erik

ebrowne wrote:When you call IROOTFORM_HandleEvent() in your main event handler with form 2 displayed, that will call helloformapp_createform2_HandleEvent(). Whatever your form's event handler returns will be returned by IROOTFORM_HandleEvent(), but you are not checking the return value of IROOTFORM_HandleEvent(). If it returns TRUE that means that one of the widgets has handled the event, and the main event handler shouldn't do anything with the event.
-Erik
i Know the menu handling is not upto the mark but i am conversant with listeners as of now. I will implement it surely but now i want to get rid of this problem.
The problem how do i check the return value of IRooTFORM_handleEvent() without disabling the AVK_Select of the main handler. The moment i put it in an if test the AVK_SELECT just does not work :(.
Thanks a lot for your advice.

ebrowne wrote:When you call IROOTFORM_HandleEvent() in your main event handler with form 2 displayed, that will call helloformapp_createform2_HandleEvent(). Whatever your form's event handler returns will be returned by IROOTFORM_HandleEvent(), but you are not checking the return value of IROOTFORM_HandleEvent(). If it returns TRUE that means that one of the widgets has handled the event, and the main event handler shouldn't do anything with the event.
-Erik
i Know the menu handling is not upto the mark but i am conversant with listeners as of now. I will implement it surely but now i want to get rid of this problem.
The problem how do i check the return value of IRooTFORM_handleEvent() without disabling the AVK_Select of the main handler. The moment i put it in an if test the AVK_SELECT just does not work :(.
Thanks a lot for your advice.

problem finally solved thaks mate it was an error in my code itself

problem finally solved thaks mate it was an error in my code itself