Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

How to force launch of VKB in CEikEdwin

From Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): S60
Platform(s): Symbian
S60 5th Edition
Keywords: CEikEdwin, CHelloWorldContainer
Created: chenziteng (27 Sep 2009)
Last edited: hamishwillee (13 Sep 2012)


Some developers would like the virtual keyboard to be displayed automatically, rather than requiring the user to first tap on the editor. The article describes how to force launch VKB in CEikEdwin by simulating a touch operation.


The solution of the specified problem is simulating a touch operation on the CEikEdwin object

void CHelloWorldContainer::LaunchVBKL()
TCursorSelection sel = iEdit1->Selection(); // remember the selection
const TInt KBorderWidth = 2;
const TInt KBorderHeight = 2;
TPointerEvent event;
event.iType = TPointerEvent::EButton1Down;
event.iParentPosition = iEdit1->PositionRelativeToScreen()+TPoint(KBorderWidth,KBorderHeight);
event.iPosition = iEdit1->Position()+TPoint(KBorderWidth,KBorderHeight);
iEdit1->HandlePointerEventL(event); // simulate a pointer down event
event.iType = TPointerEvent::EButton1Up;
iEdit1->HandlePointerEventL(event); // and then simulate a pointer up event to complete the touch operation
iEdit1->SetCursorPosL(sel.iAnchorPos, EFalse);
iEdit1->SetCursorPosL(sel.iCursorPos, ETrue); // restore the selection

Note that it is impossible to use the method to launch VKB right after the construction of the iEdit1 (in the ConstructL of the container), so if you'd like to show the VKB as soon as the container is constructed, you should run a AO and call the method in the RunL()

void CHelloWorldContainer::ConstructL( 
const TRect& aRect,
const CCoeControl* aParent,
MEikCommandObserver* aCommandObserver )
// begin by chen
iAsyncCallBack = new(ELeave) CAsyncCallBack(TCallBack(AsyncCallBack, this), CActive::EPriorityStandard);
iAsyncCallBack->CallBack(); // AO that runs only once
// end by chen
TInt CHelloWorldContainer::AsyncCallBack(TAny* aParam)
return KErrNoMemory;
CHelloWorldContainer* self = static_cast<CHelloWorldContainer*>(aParam);
TRAPD(err, self->LaunchVBKL());
return err;

Full example: HelloWorld(LaunchVKB).zip

Related articles (and discussions):


How to force launch of VKB in FEP-aware custom control

"How to pop up virtual keyboard when view is shown"

This page was last modified on 13 September 2012, at 06:38.
33 page views in the last 30 days.