×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Apr 2006
    Posts
    54

    Key event problem

    My application work in the background. I need to detect key event (num 4) and send it to foreground.


    My appui construct:

    void CHelloWorldBasicAppUi::ConstructL()
    {

    BaseConstructL();

    iAppView = CHelloWorldBasicAppView::NewL(ClientRect());

    AddToStackL(iAppView);

    CEikonEnv::Static()->RootWin().EnableReceiptOfFocus(EFalse);
    CEikonEnv::Static()->RootWin().SetOrdinalPosition(-1000, ECoeWinPriorityNeverAtFront);

    RWindowGroup iWindowGroup = CCoeEnv::Static() -> RootWin();
    TInt32 iCallBackHandle = iWindowGroup.CaptureKey(EKeyApplication0, 0, 0);
    iWindowGroup.CancelCaptureKey(iCallBackHandle);
    }
    My appui HandleKeyEventL
    TKeyResponse CHelloWorldBasicAppUi::HandleKeyEventL(
    const TKeyEvent& /*aKeyEvent*/ ,TEventCode /*aType*/)
    {
    return EKeyWasNotConsumed;
    }
    Other method's in my appui:
    // ----------------------------------------------------
    // CMyAppUi::SendToBackground()
    // Send the application to background.
    // ----------------------------------------------------
    //
    void CHelloWorldBasicAppUi::SendToBackground()
    {
    // Construct en empty TApaTask object
    // giving it a reference to the Window Server session
    TApaTask task(iEikonEnv->WsSession( ));

    // Initialise the object with the window group id of
    // our application (so that it represent our app)
    task.SetWgId(CEikonEnv::Static()->RootWin().Identifier());

    // Request window server to bring our application
    // to background
    task.SendToBackground();
    }

    // ----------------------------------------------------
    // CMyAppUi::BringToForeground()
    // Bring the application to foreground.
    // ----------------------------------------------------
    //
    void CHelloWorldBasicAppUi::BringToForeground()
    {
    // Construct en empty TApaTask object
    // giving it a reference to the Window Server session
    TApaTask task(iEikonEnv->WsSession( ));

    // Initialise the object with the window group id of
    // our application (so that it represent our app)
    task.SetWgId(CEikonEnv::Static()->RootWin().Identifier());

    // Request window server to bring our application
    // to foreground
    task.BringToForeground();
    }


    // ---------------------------------------------------------
    // CTextTrisContainer::HandleKeyEvent
    // Translate the key events to Game specific key events.
    // ---------------------------------------------------------
    //
    TKeyResponse CHelloWorldBasicAppUi::OfferKeyEventL( const TKeyEvent& aKeyEvent ,TEventCode aType )
    {
    switch( aType )
    {
    case( EEventKeyDown ):
    {
    switch( aKeyEvent.iScanCode )
    {
    case( 0x34 ): //For the 4 key
    {
    BringToForeground();
    break;
    }

    default:
    break;
    }
    break;
    }
    case( EEventKeyUp ):
    {
    switch( aKeyEvent.iScanCode )
    {

    case( 0x34 ): //For the 4 key
    {
    SendToBackground();
    break;
    }
    default:
    break;
    }
    break;
    }
    default:
    {
    break;
    }
    }

    return EKeyWasConsumed;
    }

    In Document i use this to hide application:

    void CHelloWorldBasicDocument::UpdateTaskNameL(CApaWindowGroupName* aWgName)
    {
    CEikDocument::UpdateTaskNameL(aWgName);
    aWgName->SetHidden(ETrue);

    }

    But this is don't work. There i can make mistakes? Detecting key event?

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: Key event problem

    from SDK help:
    KeyApplication0 == Code for an Application launcher key.


    So it is not number 4 you are capturing.

    yucca

  3. #3
    Regular Contributor
    Join Date
    Apr 2006
    Posts
    54

    Re: Key event problem

    2yucca -> can i use this application in the simulator?

  4. #4
    Regular Contributor
    Join Date
    Apr 2006
    Posts
    54

    Re: Key event problem

    With EKeyApplication0 - ... don't work too.

  5. #5
    Registered User
    Join Date
    Apr 2005
    Location
    Barcelona
    Posts
    1,678

    Re: Key event problem

    You need to implement the appui's HandleWsEventL() function

  6. #6
    Regular Contributor
    Join Date
    Apr 2006
    Posts
    54

    Re: Key event problem

    2PushL: Do you have example, how to use HandleWsEventL()?

Similar Threads

  1. Simulating Long Key Press event in debugging mode...
    By empeegee in forum Multimodecards
    Replies: 1
    Last Post: 2004-12-18, 06:31
  2. background server listen key event
    By ysdl in forum Symbian
    Replies: 2
    Last Post: 2004-08-04, 10:45
  3. How to simulate a long key event ??
    By thanhnguyen in forum Symbian
    Replies: 0
    Last Post: 2004-01-06, 09:27
  4. How to get key event in CAknMessageQueryDialog
    By kcome in forum Symbian User Interface
    Replies: 0
    Last Post: 2003-11-19, 03:49
  5. Replies: 0
    Last Post: 2003-11-14, 07:58

Posting Permissions

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