HandleKeyEventL not hiting

Login to reply to this topic.
Mon, 2006-10-30 20:59
Joined: 2005-09-30
Forum posts: 35
Hi All,
  I am getting strange problem in my project. I overloaded HandleWsEventL(), HandleKeyEventL() and OfferKeyEventL().

Whenever I press any key event, focus is coming to HandleWsEventL() and it calls OfferKeyEventL(). The problem is eventhough I am not consuming the key event in OfferKeyEventL(), my function HandleKeyEventL() is not getting called.

Can anyone help me where I have done wrong.

Thanks in advance...
mos

Tue, 2006-10-31 05:27
Forum Nokia Champion
Joined: 2004-05-26
Forum posts: 732
Re: HandleKeyEventL not hiting
The functions HandleWsEventL() and HandleKeyEventL() are defined in class CCoeAppUi, while the function OfferKeyEventL() is defined in the class CCoeControl.

Which class did you derive your class? Please give more details.

Tue, 2006-10-31 05:52
Joined: 2005-09-30
Forum posts: 35
Re: HandleKeyEventL not hiting
Thanks for your response.
My appui class is derived from CAknViewAppUi while I have my view and container classes separately.

class CMyAppUi : public CAknViewAppUi
{
public:
   void HandleWsEventL(const TWsEvent& aEvent,CCoeControl* aDestination);

TKeyResponse HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
};

class CMyView : public CAknView
{
};

class CMyContainer : public CCoeControl, MCoeControlObserver
{
   public: // From CoeControl
        TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,TEventCode aType );
};

Thanks in advance.
mos
Tue, 2006-10-31 06:35
Forum Nokia Champion
Joined: 2004-05-26
Forum posts: 732
Re: HandleKeyEventL not hiting
The class/function definitions seem to be correct. But did you go through the SDK document for the function HandleWsEventL()?

It says:

Quote
Description

Handles events sent to the application by the window server.

This function is called whenever the window server sends key or pointer events or some other special events to the application. It calls one of a number of functions, according to the type of event.

For key events, it calls CCoeControl::OfferKeyEventL() for each control on the control stack, beginning with the control at the top (position 0) until a control consumes it. If no control on the stack consumes the key event, the app UI's HandleKeyEventL() is called. Note that CCoeControl::OfferKeyEventL() is not called for controls whose ECoeStackFlagRefusesAllKeys flag is set.
...
...

Tue, 2006-10-31 06:53
Joined: 2004-07-09
Forum posts: 108
Re: HandleKeyEventL not hiting
Hi mos13,

As per document says, It is not recommenened to override

HandleKeyEventL() in derived class.

If you intended to override this function, you should also override InputCapabilities() virtual function, returning a TCoeInputCapabilities object whose attributes correspond to the behavior of the HandleKeyEventL() function.

In the implementation of HandleWsEventL function , Pass the key event to window server.

CEikAppUi::HandleWsEventL(aEvent,aDestination);

May be it solves your problem.



DipakBaviskar

Tue, 2006-10-31 07:00
Joined: 2005-09-30
Forum posts: 35
Re: HandleKeyEventL not hiting
Hi vin2ktalks,
As SDK documents says:
>>For key events, it calls CCoeControl::OfferKeyEventL() for each >>control on the control stack, beginning with the control at the top >>(position 0) until a control consumes it. If no control on the stack >>consumes the key event, the app UI's HandleKeyEventL() is >>called.

I am also doing the same thing. I am not consuming the KeyEvent in my OfferKeyEventL(), as per document it should call my HandleKeyEventL().
TKeyResponse CMyContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,TEventCode aType )
{
      if(aKeyEvent.iScanCode == 56) // When I press 't'
        return EKeyWasNotConsumed;
}
Thanks
mos
Tue, 2006-10-31 07:15
Forum Nokia Champion
Joined: 2004-05-26
Forum posts: 732
Re: HandleKeyEventL not hiting
Have you created any controls in your CMyContainer class? Like list box or something?

Tue, 2006-10-31 07:41
Joined: 2005-09-30
Forum posts: 35
Re: HandleKeyEventL not hiting
Hi vin2ktalks,
  yes, I created Listbox in my contianer class and also override method HandleListBoxEventL() in my container class.

Thanks
mos
Tue, 2006-10-31 07:58
Joined: 2005-09-30
Forum posts: 35
Re: HandleKeyEventL not hiting
Hi Dip,
  I override InputCapabilities() in my AppUi class but still focus is not coming in my HandleKeyEventL() function when I press any key and not comsuming key event anywhere.

TCoeInputCapabilities CMyAppUi::InputCapabilities() const
{
  return (TCoeInputCapabilities::EAllText | TCoeInputCapabilities::ENavigation);
}

Thanks
mos
Tue, 2006-10-31 08:18
Joined: 2005-09-30
Forum posts: 35
Re: HandleKeyEventL not hiting
Hi,
  Just want to add one more point.
My application is based on SMS. So, once I click my application icon, the focus comes to HandleKeyEventL() through HandleWsEventL(); but after receiveing the Loggin message from the server(running on differrent system) the focus is not coming to my HandleKeyEventL().

thanks
mos
Tue, 2006-10-31 08:44
Forum Nokia Champion
Joined: 2004-05-26
Forum posts: 732
Re: HandleKeyEventL not hiting
Generally by over-riding the OfferKeyEventL() from the CCoeControl to your control class you can trap the key presses(for that your application should be on foreground). I did that and worked for me. I never over-ridded HandleWsEventL() and HandleKeyEventL() into my AppUi class in that cases.

Quote from: mos13
...
{
      if(aKeyEvent.iScanCode == 56) // When I press 't'
        return EKeyWasNotConsumed;
}
...

For which device are you developing the application?

Tue, 2006-10-31 09:46
Joined: 2005-09-30
Forum posts: 35
Re: HandleKeyEventL not hiting
Hi vin2ktalks,
  I am developing for 6600,6630 and I am using version 7 series60 2nd edition.  I can consumed the key event in OfferKeyEventL() but in my application I have 10 views. So, for hotkey I want to make my code generic so that I can consume hotkey event in HandleKeyEventL() instead of consuming in OfferKeyEventL of all the containers.
Thanks
mos
Wed, 2008-05-28 13:16
Joined: 2008-05-05
Forum posts: 13
How to Display A message when a key is pressed

Hi

i am new to symbian os so any body will help me to write a program that will display a message when i pressed a key ..

PLZ reply ASAP

  • Login to reply to this topic.