首 页 | 新 闻 | Symbian | Android| Windows Mobile | J2ME | 下载中心 | 游戏策划招聘与求职 | 购书指南 | 视频教程
您现在的位置: 开发视界 >> Symbian英文资料 >> User Interface >> 正文
How to handle Focus On Controls on Down and Up Errow in Nokia Series60 Platform
作者:佚名    文章来源:不详    更新时间:2006-5-7 11:20:22

As Nokia Series 60 platform uses model view controller pattern for user Interface, each view is activated and deactivated by framework; now how we can handle focus events on multiple controls on key up and key down events and set the focus ? Because in Nokia Series60 Avkon Environment all the controls are derived from base class CCoeControl here is how we can solve this problem...

Suppose there are Three controls in one Appview container two are edit windows and one is secret editor as follows

Define the following data member in your view or container class:

#define KNumOfEdwin            2
#define KNumofSecretEditors    1
#define KTotalNumberOfControls 3

class CYourView: public CCoeControl
{
...
private:
CEikEdwin*        iPtrEditorWindows[KNumofEdwin];
CEikSecretEditor* iPtrSecretEditor;//Only One
CCoeControl*      iPtrToFocusControls[KTotalNumberOfControls];
}

In the second phase constructor of your class, after initializaing editor and secret editor controls just write the code:


for(TInt iIndex = 0;iIndex < KNumberOfEdwin;iIndex++)
{
 iPtrToFocusControls[iIndex] = iPtrEditorWindows[Index];
}
iPtrToFocusControls[iIndex] = iPtrSecretEditor;

Now in function OfferKeyEventL, we can handle focus control events like this:


for (TInt iIndex = 0; iIndex < KTotalNumberofControls; iIndex++)
{
 if (iPtrToFocusControls[iIndex]->IsFocused())
 {
   // Move focus to previous control.
   if ((aType == EEventKey) && (aKeyEvent.iCode == KeyUpArrow))
   {
     iPtrToFocusControls[iIndex]->SetFocus(EFalse);
     if (iIndex == 0)    // if first control, move focus to last.
     {
       iIndex = KTotalNumberofControls;
     }
     iPtrToFocusControls[iIndex - 1]->SetFocus(ETrue);
     return EKeyWasConsumed;
   }
   // Move focus to next control.
   else if((aType == EEventKey)&&(aKeyEvent.iCode == EKeyDownArrow))
   {
     iPtrToFocusControls[iIndex]->SetFocus(EFalse);
     if(iIndex == KTotalNumberofControls - 1)
     {
       iIndex = -1;    // if last control, move focus to first.
     }
     iPtrToFocusControls[iIndex + 1]->SetFocus(ETrue);
     return EKeyWasConsumed;
   }
   // default action.
   else
   {
      return iPtrToFocusControls[iIndex]->OfferKeyEventL(aKeyEvent, aType);  
   }
 }
}
return EKeyWasNotConsumed;

This will focus on control on down and up error keys: Isn’t it so simple.

Bhuvnesh Joshi.
joshi_bhuvnesh@yahoo.com

相关文章:
Integrating LeaveScan into Codewarrior 3.x
Carbide.c++: Setting up On Target Debugging
Using SIP with Nokia Series60 and Asterisk
How to get a Series 60 phone firmware version number ?
How to identify a mobile at execution or installation time
Compress Your Symbian C++ Executables
Common products UIDs
How to compile for WINSCW without a CodeWarrior or Visual Studio IDE
 

站点地图 | 加入收藏 | 联系站长 | 广告服务 |
QQ:280529124  Tel:0592-8271361 辽ICP备05021703号