number pad key presses
| Wed, 2005-06-15 04:59 | |
|
Hi,
I have posted this at forum.nokia as well, so sorry to those who read both forums... I want to be able to check for number (0 - 9) keypresses in the HandleKeyEventL in AppUi. I have previously used EStdKeyLeftArrow and EStdKeyRightArrow, but cannot find an equivalent for 0 - 9. I have tried using EStdKeyNkp1 etc but these don't seem to work at all. Does anyone know how to do this? Thanks in advance, Miranda |
|






Forum posts: 69
I am also wanting to solve this problem.
Miranda, let me know if you have been able to find a solution to this
regards,
sourabh
Forum posts: 70
Forum posts: 56
You should use EStdKeyNkp1 - EStdKeyNkp0 constants. I'm not sure, but the possible reason why you cann't handle it in HandleKeyEventL() is that some component, handles it earlier. To avoid this just do the following. Instead of handling numpad presses in HandleKeyEventL() handle it in CEikAppUi::HandleWsEventL().
It should look something like this:
{
if(aEvent.Type() == EEventKeyUp)
{
TKeyEvent* event = aEvent.Key();
switch(event->iScanCode)
{
case EStdKeyNkp1:
DoSomething1();
break;
case EStdKeyNkp2:
DoSomething2();
break;
case EStdKeyNkp3:
DoSomething3();
break;
case EStdKeyNkp4:
DoSomething4();
break;
case EStdKeyNkp5:
DoSomething5();
break;
case EStdKeyNkp6:
DoSomething6();
break;
case EStdKeyNkp7:
DoSomething7();
break;
case EStdKeyNkp8:
DoSomething8();
break;
case EStdKeyNkp9:
DoSomething9();
break;
case EStdKeyNkp0:
DoSomething0();
break;
}
break;
}
else
{
CYourAppUiBaseClass::HandleWsEventL(aEvent, aDestination);
}
}
hope this helps!
Regards.
Forum posts: 6
try using the normal char-codes '0', '1', ... , '9'
Bye,
Chris
Forum posts: 70
I tried HandleWsEventL and it didn't register number presses either unfortunately, but I tried using the normal char codes and it worked!
So I ended up with:
{
   if (aType == EEventKey) {Â
switch (aKeyEvent.iScanCode)
{
case '1':
{
//do something
return EKeyWasConsumed;
}
case '4':
{
//do something
return EKeyWasConsumed;
}
}
   }
   return EKeyWasNotConsumed;
}
Thanks everyone for your help.
Forum posts: 27
TKeyResponse CmyView::OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType)
{
if (aType == EEventKeyDown)
{
TInt i=1000;
switch (aKeyEvent.iScanCode)
{
case EStdKeyNkp1:
{
//DoSomething
return EKeyWasConsumed;
break;
}
case EStdKeyNkp2:
{
//DoSomething
return EKeyWasConsumed;
break;
}
case EStdKeyNkp3:
{
//DoSomething
break;
case EStdKeyNkp5:
{
//DoSomething
return EKeyWasConsumed;
break;
}
case EStdKeyNkp6:
{
//DoSomething
return EKeyWasConsumed;
break;
}
}
}}
This will work very much fine in UIQ.....
correct me if m worng