×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    6

    How to pop up virtual keyboard when view is shown

    I have a view in my application that contains only a single CEikEdwin, which has the focus when the view appears. On the 5th edition handsets, as soon as the view is displayed, I would like the virtual keyboard to be displayed automatically, rather than requiring the user to first tap on the editor.

    I'm aware of the code for forcing the VKD to display:
    Code:
    MCoeFepAwareTextEditor_Extension1 * extension1 = editor->InputCapabilities().FepAwareTextEditor()->Extension1();
    CAknEdwinState * aknEdwinState = static_cast<CAknEdwinState *> (extension1->State(KNullUid));
    aknEdwinState->ReportAknEdStateEventL(MAknEdStateObserver::EAknActivatePenInputRequest);
    but I'm not having any luck with it.

    I suspect that my problem is exactly when I should call the above code in the sequence to have it take effect. I've tried doing it just after the CEikEdwin is constructed and configured, and I've also tried it just after the container has been added to the control stack, but neither seems to take effect - the user still has to tap on the editor to get the virtual keyboard to display.

    Can someone enlighten me on exactly when in the sequence of getting my view up I should call this code?

  2. #2
    Super Contributor
    Join Date
    Nov 2004
    Posts
    1,009

    Re: How to pop up virtual keyboard when view is shown

    I think you will have to simulate the touch down and release pointer events for the control to make VKB visible.
    http://wiki.forum.nokia.com/index.ph...Pointer_Events
    Regards,
    Shafali

  3. #3
    Nokia Developer Champion
    Join Date
    Jan 2008
    Location
    Moscow, Russia
    Posts
    3,348

    Re: How to pop up virtual keyboard when view is shown

    Try to set the focus on editor using SetFocus( ETrue ) method.

    Quote Originally Posted by shafali gupta View Post
    I think you will have to simulate the touch down and release pointer events for the control to make VKB visible.
    http://wiki.forum.nokia.com/index.ph...Pointer_Events
    Link is broken. Fixed link - Simulating Pointer Events

  4. #4
    Nokia Developer Champion
    Join Date
    May 2004
    Posts
    2,267

    Re: How to pop up virtual keyboard when view is shown

    Hi,

    I found that if you simulate pointer events during container construction (right after the edwin construction) then the VBK will not be launched.

    Code:
    // note: the code is NOT gonna work
    void CHelloWorldContainer::ConstructL( ...
    		{
    		...
    		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);
    		event.iType = TPointerEvent::EButton1Up;
    		iEdit1->HandlePointerEventL(event);
    		}
    But if you run the same code in an AO's RunL() then the VBK can be launched (verified on S60 5th emulator).

    Code:
    // .h
    
    class CHelloWorldContainer : public CCoeControl
    	{
    	...
    // begin by chen
    private:
    	void LaunchVBKL();
    
    	static TInt AsyncCallBack(TAny* aParam);
    
    private:
    	CAsyncCallBack* iAsyncCallBack;
    // end by chen
    	};
    Code:
    // .cpp
    
    CHelloWorldContainer::~CHelloWorldContainer()
    	{
    // begin by chen
    	delete iAsyncCallBack;
    // end by chen
    	...
    	}
    				
    void CHelloWorldContainer::ConstructL( 
    	...
    	{
    	...
    // begin by chen
    	iAsyncCallBack = new(ELeave) CAsyncCallBack(TCallBack(AsyncCallBack, this), CActive::EPriorityStandard);
    	iAsyncCallBack->CallBack();
    // end by chen
    	}
    
    // begin by chen
    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);
    		event.iType = TPointerEvent::EButton1Up;
    		iEdit1->HandlePointerEventL(event); // show me the VBK !
    
    		iEdit1->SetCursorPosL(sel.iAnchorPos, EFalse);
    		iEdit1->SetCursorPosL(sel.iCursorPos, ETrue); // restore the selection
    		}	
    	}
    
    TInt CHelloWorldContainer::AsyncCallBack(TAny* aParam)
    	{
    	if(aParam==NULL)
    		{
    		return KErrNoMemory;
    		}
    	CHelloWorldContainer* self = static_cast<CHelloWorldContainer*>(aParam);
    	TRAPD(err, self->LaunchVBKL());
    	return err;
    	}
    // end by chen
    Regards

    Ziteng Chen

  5. #5
    Registered User
    Join Date
    Apr 2008
    Posts
    6

    Re: How to pop up virtual keyboard when view is shown

    Quote Originally Posted by chenziteng View Post
    Hi,

    I found that if you simulate pointer events during container construction (right after the edwin construction) then the VBK will not be launched.
    I neglected to mention that I had already tried that, but obviously it's a matter of exactly when the pointer events occur. I should have thought of delaying them slightly with an AO. Thanks!

    Kevin

  6. #6
    Registered User
    Join Date
    Dec 2007
    Posts
    23

    Re: How to pop up virtual keyboard when view is shown

    As I remember, if this code:
    Code:
    MCoeFepAwareTextEditor_Extension1 * extension1 = editor->InputCapabilities().FepAwareTextEditor()->Extension1();
    CAknEdwinState * aknEdwinState = static_cast<CAknEdwinState *> (extension1->State(KNullUid));
    aknEdwinState->ReportAknEdStateEventL(MAknEdStateObserver::EAknActivatePenInputRequest);
    is called async after construction, VKB appears. I used RTimer for async event.

Similar Threads

  1. CPbkContactEditorDlg customize
    By asdfghjkl_asdfghjkl in forum Symbian
    Replies: 5
    Last Post: 2008-08-05, 02:56
  2. Replies: 1
    Last Post: 2002-10-29, 13:25

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×