CEikFloatingPointEditor控件的问题
我写的最简单的+,-计算器,导航键向上加向下减,但是不知道哪里的问题,运行时只能写数字,却不能运算,不知为何?请大家帮助一下TKeyResponse CHelloworldContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent,
TEventCode aType )
{
if ( aType != EEventKey ) // Is not key event?
{
return EKeyWasNotConsumed;
}
TReal dt;
CAknNumericEdwin::TValidationStatus ageStatus;
switch ( aKeyEvent.iCode )
{
case EKeyDownArrow:
aOpe ='-';
ageStatus =iFloatingPointEditor1->GetValueAsReal(dt);
if(ageStatus==CAknNumericEdwin::EValueValid)aElem1=dt;
return EKeyWasConsumed;
break;
case EKeyUpArrow:
aOpe ='+';
ageStatus =iFloatingPointEditor1->GetValueAsReal(dt);
if(ageStatus==CAknNumericEdwin::EValueValid)aElem1=dt;
return EKeyWasConsumed;
break;
case EKeyEnter:
ageStatus =iFloatingPointEditor1->GetValueAsReal(dt);
if(ageStatus==CAknNumericEdwin::EValueValid)
{
aElem2=dt;
TReal res;
if (aOpe=='-')
res = aElem1-aElem2;
else if (aOpe=='+')
res = aElem1+aElem2;
iFloatingPointEditor1->SetValueL(&res);
}
return EKeyWasConsumed;
break;
default:
if(iFloatingPointEditor1)
{
return iFloatingPointEditor1->OfferKeyEventL(aKeyEvent, aType );
}
else
{
return EKeyWasNotConsumed;
}
}
return EKeyWasConsumed;
}
补充:移动开发 , Symbian