Archived:How to toggle the input mode of an editor using Symbian C++
Article Metadata
Compatibility
Article
Overview
How to programmatically toggle the input mode of an editor
Description
By simulating the hash (#) key event, it is possible to toggle the input mode of the currently focused editor between normal and numeric modes.
-----
#include <ptidefs.h> // for EPtiKeyHash
RWsSession wSess;
User::LeaveIfError( wSess.Connect() );
TInt wgId = wSess.GetFocusWindowGroup();
if( wgId != KErrNotFound )
{
TWsEvent keypress;
keypress.Key()->iCode = EPtiKeyHash;
keypress.Key()->iScanCode = 0;
keypress.Key()->iModifiers = 0;
keypress.Key()->iRepeats = 1;
keypress.SetType(EEventKeyDown);
keypress.SetTimeNow();
wSess.SendEventToWindowGroup( wgId, keypress );
User::After(2000);
keypress.SetType(EEventKey);
keypress.SetTimeNow();
wSess.SendEventToWindowGroup( wgId, keypress );
User::After(2000);
keypress.SetType(EEventKeyUp);
keypress.SetTimeNow();
wSess.SendEventToWindowGroup( wgId, keypress );
}
Note: On S60 3rd Edition devices, the following code requires SwEvent capability.
Note: This does not work in devices with a full keyboard.


This trick won't work for devices with full keyboard (E61).
Thank you for your feedback. The article has been updated.
Forum Nokia KB 07:03, 14 September 2007 (UTC)