×
Namespaces

Variants
Actions
Revision as of 06:38, 13 September 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

How to force launch of VKB in CEikEdwin

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

Overview

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.


Solution

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


void CHelloWorldContainer::LaunchVBKL()
{
if(iEdit1!=NULL)
{
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)
{
if(aParam==NULL)
{
return KErrNoMemory;
}
CHelloWorldContainer* self = static_cast<CHelloWorldContainer*>(aParam);
TRAPD(err, self->LaunchVBKL());
return err;
}

Full example: HelloWorld(LaunchVKB).zip

Related articles (and discussions):

VKB

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.
46 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×