number pad key presses

Login to reply to this topic.
Wed, 2005-06-15 04:59
Joined: 2005-02-16
Forum posts: 70
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

Wed, 2005-06-15 07:38
Joined: 2004-10-25
Forum posts: 69
Re: number pad key presses
 
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
Thu, 2005-06-16 07:28
Joined: 2005-02-16
Forum posts: 70
Re: number pad key presses
no one knows? surely this is something that is needed in many applications???  Huh
Thu, 2005-06-16 09:34
Joined: 2004-05-24
Forum posts: 56
Re: number pad key presses
Hi,

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:

Code:
void CYourAppUi::HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDestination)
{
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.
Thu, 2005-06-16 13:11
Joined: 2005-02-10
Forum posts: 6
Re: number pad key presses
Hallo Miranda,

try using the normal char-codes '0', '1', ... , '9'

Bye,

Chris
Fri, 2005-06-17 01:38
Joined: 2005-02-16
Forum posts: 70
Re: number pad key presses
Thanks for the replies!
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:
Code:
TKeyResponse CpixelsContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
{
      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.
Mon, 2008-04-28 13:44
Joined: 2008-04-11
Forum posts: 27
Re: number pad key presses

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

  • Login to reply to this topic.