OfferKeyEventL不能响应按键操作?

写了测试代码测试按键控制。
重载了OfferKeyEventL函数

  1. TKeyResponse CMyTest_S60AppView::OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType){
  2. // We only want the key press, not the key up/down event
  3.  if ( aType == EEventKey )
  4.  {
  5.    // Check if the 2 key was pressed
  6.    if ( aKeyEvent.iCode == '1' )
  7.    {    
  8.     iKeyPressCount ++;
  9.     return EKeyWasConsumed;
  10.    }
  11.    return EKeyWasNotConsumed;
  12. }

编译运行,可是怎么按都没有响应,在Debug 中下断点,也不停下来。

后来到Nokia论坛看了一下,发现使用 AddToStackL(iAppView); 添加到列表中才能处理按键响应。

  1. void CMyTest_S60AppUi::ConstructL()
  2.  {
  3.  // Initialise app UI with standard value.
  4.  BaseConstructL();
  5.  
  6.  // Create view object
  7.  iAppView = CMyTest_S60AppView::NewL( ClientRect() );
  8.  
  9.  AddToStackL(iAppView);
  10.  
  11.  PrivacyStatementL();
  12.  iAppView->BeginSession();
  13. }

Popularity: 4% [?]

Related

Comments

One Response to “OfferKeyEventL不能响应按键操作?”

  1. zuii on August 29th, 2009 1:23 am

    原来是这个原因,晕了…

    [Reply]