|
|
Classification: |
C++ |
Category: |
Application Architecture |
Created: |
07/26/2001 |
Modified: |
09/11/2002 |
Number: |
FAQ-0717 |
Platform: |
Symbian OS v6.0, Symbian OS v6.1, Symbian OS v7.0, Symbian OS v7.0s |
|
Question: How to I use the Virtual Cursor introduced to UIKON in V6.0 of the Symbian OS?
Answer: The Virtual Cursor was introduced to the OS to allow devices lacking a touch-sensitive screen to emulate the use of a pointing
device using a combination of the arrow keys, the Enter key and the Shift keys. The cursor is quite simple to use - enable
it in your code and then when the correct key combinations are used (see below) your application will receive pointer events
just as it would if a pen were present. This is especially useful when porting code (e.g. custom controls, views, etc.) which
already handles pointer events because minimal changes are required.
Enabling the virtual cursor from a user's perspective is typically done via a menu option which can be alternated between
on and off. In your AppUi class this would translate to:
void CMyAppUi::CmdVirtualCursorChangeStateL(){ // Virtual cursor-important to check against EOff, since there are three states // (EOn, ESuspended, EOff), ESuspended treated as cursor being on but suspended. TRect newArea;
if(IsVirtualCursorOn()){ newArea = iCursorAreaBeforeVC; // Member variable of type TRect iVCState = TEikVirtualCursor::EOff; // Member variable of type TEikVirtualCursor }else{ iCursorAreaBeforeVC = iEikonEnv->WsSession().PointerCursorArea(); newArea = ClientRect(); iVCState = TEikVirtualCursor::EOn; }
iEikonEnv->WsSession().SetPointerCursorArea(newArea); iEikonEnv->VirtualCursor().SetCursorStateL(iVCState,*iEikonEnv); }
TBool CMyAppUi::IsVirtualCursorOn() const { // Virtual cursor-important to check against EOff, since there are three states // (EOn, ESuspended, EOff), ESuspended treated as cursor being on but suspended. return (iEikonEnv->VirtualCursor().CursorState(*iEikonEnv)!=TEikVirtualCursor::EOff); }
When the virtual cursor is switched on by the user, some keypresses have specific meanings: The key will generate a "pointer
down" event when pressed and "pointer up" event when released. In addition, when the modifier is used in conjunction with
the arrow keys, drag events will be generated. The arrow keys themselves with no modifiers serve to move the virtual cursor
about on screen (no events will be generated for this).
|
|
|