Hello,
I've got a weird problem with ListBox which is extremely frustrating and annoying to me. It has always caused my phone to reboot everytime I hit Up, Down and OK key. This was also posted by someone else here, but no single answer was given to him.
My code:
Please help me solve this terrible error.Code:TKeyResponse CPengawas_Logs::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) { TKeyResponse Ret = EKeyWasNotConsumed; if(aType != EEventKey || iListBox == NULL || !iListBox->IsFocused()) { return EKeyWasNotConsumed; } switch(aKeyEvent.iCode) { case EKeyUpArrow: { if (iItemCount > 1) { iAppUi->SaveToLog(KFileLog, _L("EKeyUpArrow - iListBox->CurrentItemIndex() = "), ETrue, iListBox->CurrentItemIndex()); if (iListBox->CurrentItemIndex() > 0) iSelectedItemIndex = iListBox->CurrentItemIndex() - 1; else iSelectedItemIndex = iItemCount - 1; iAppUi->iActiveItemIndex = iSelectedItemIndex; iAppUi->SaveToLog(KFileLog, _L("EKeyUpArrow - iAppUi->iActiveItemIndex = "), ETrue, iAppUi->iActiveItemIndex); iAppUi->SaveToLog(KFileLog, _L("EKeyUpArrow - ShowDateTimeAndItemNumber")); ShowDateTimeAndItemNumber(iItemCount); iAppUi->SaveToLog(KFileLog, _L("EKeyUpArrow - ShowDateTimeAndItemNumber - DONE")); iAppUi->SaveToLog(KFileLog, _L("Ret = iListBox->OfferKeyEventL")); Ret = iListBox->OfferKeyEventL( aKeyEvent, aType ); //This line always fails (nothing was written to log afterwards), resulting in phone reboot iAppUi->SaveToLog(KFileLog, _L("Ret = iListBox->OfferKeyEventL - DONE")); //Ret = EKeyWasConsumed; } // Forward up key press events to the list box //return iListBox->OfferKeyEventL( aKeyEvent, aType ); return Ret; } case EKeyDownArrow: { if (iItemCount > 1) { iAppUi->SaveToLog(KFileLog, _L("EKeyDownArrow - iListBox->CurrentItemIndex() = "), ETrue, iListBox->CurrentItemIndex()); if (iListBox->CurrentItemIndex() < iItemCount - 1) iSelectedItemIndex = iListBox->CurrentItemIndex() + 1; else iSelectedItemIndex = 0; iAppUi->iActiveItemIndex = iSelectedItemIndex; iAppUi->SaveToLog(KFileLog, _L("EKeyUpArrow - iAppUi->iActiveItemIndex = "), ETrue, iAppUi->iActiveItemIndex); iAppUi->SaveToLog(KFileLog, _L("EKeyDownArrow - ShowDateTimeAndItemNumber")); ShowDateTimeAndItemNumber(iItemCount); iAppUi->SaveToLog(KFileLog, _L("EKeyDownArrow - ShowDateTimeAndItemNumber - DONE")); iAppUi->SaveToLog(KFileLog, _L("Ret = iListBox->OfferKeyEventL")); Ret = iListBox->OfferKeyEventL( aKeyEvent, aType ); //This line fails all the time, leading to phone reboot as well iAppUi->SaveToLog(KFileLog, _L("Ret = iListBox->OfferKeyEventL - DONE")); //Ret = EKeyWasConsumed; } // Forward down key press events to the list box //return iListBox->OfferKeyEventL( aKeyEvent, aType ); return Ret; } case EKeyOK: { if (iItemCount > 0) { iAppUi->SaveToLog(KFileLog, _L("EKeyOK - iListBox->CurrentItemIndex() = "), ETrue, iListBox->CurrentItemIndex()); iSelectedItemIndex = iListBox->CurrentItemIndex(); iAppUi->iActiveItemIndex = iSelectedItemIndex; iAppUi->SaveToLog(KFileLog, _L("EKeyOK - iAppUi->iActiveItemIndex = "), ETrue, iAppUi->iActiveItemIndex); iAppUi->SaveToLog(KFileLog, _L("EKeyOK - About to activate another view")); iAppUi->ActivateLocalViewL(TUid::Uid(EPengawas_RincianViewId)); //This line "apparently" succeeds as the next line was executed, though phone reboot still occurs all the time... iAppUi->SaveToLog(KFileLog, _L("EKeyOK - Another view might have been activated")); //The log was successfully appended //return EKeyWasConsumed; } return EKeyWasConsumed; } default: break; } //return EKeyWasNotConsumed; //return Ret; //CCoeControl::OfferKeyEventL( aKeyEvent, aType); activating/deactivating this line did not make a difference }
Thanks in advance.
Regards,
Asep

Reply With Quote
. Hope it's not offensive or found to be against the law, because I do it only to conceal the true identity and behavior of that app I've been developing, for MY OWN needs. I will not publish it to anyone else (apart from my SINGLE target user) until I change the name. 

