Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User vikhyath's Avatar
    Join Date
    Oct 2006
    Posts
    24
    Hi,

    I am interested in trying to pick up all the key events that are produced on the phone, and then check it against a particular key which triggers a function in my application.

    I used

    iKeyHandle =
    CEikonEnv::Static()->RootWin().CaptureKetUpAndDowns(EStdKeyF3,0,0);

    and then handled key events in
    CSymbian1AppUi::HandleWsEventL (const TWsEvent &aEvent, CCoeControl *aDestination)
    { ...........}

    This works fine but I need to pick up events that occur when my application is not in focus, and this is not happening. Can someone give me any suggestions as to why this is not working or how to make it work?

    Thanks ,

    Vikhyath

  2. #2

  3. #3
    Registered User vikhyath's Avatar
    Join Date
    Oct 2006
    Posts
    24
    Hi I tried the example from the thread above. I had tried it previously as well, but either the screen stays permanantly with my app in the foreground else it does not pick up keypresses in other apps. I have added comments to the code below:

    I would really appreciate help... I am working using series 80 sdk.

    Thanks,

    Vikhyath

    void CSymbian1AppUi::ConstructL()
    {
    BaseConstructL();

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

    AddToStackL(iAppView);


    // set application as system application so that it will not be closed by
    // system events
    CEikonEnv::Static()->SetSystem( ETrue );
    // capture red key permanently
    iHashKeyHandle = CEikonEnv::Static()->RootWin().CaptureKeyUpAndDowns(EStdKeyHash, 0, 0);

    // set application priority to foreground priority even if it goes to background
    //This line seems to make no difference
    //CEikonEnv::Static()->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
    //with this line, even if i open anoter app, the screen stays with this app
    //CEikonEnv::Static()->WsSession().ComputeMode( RWsSession::EPriorityControlDisabled );

    //these lines dont do anything
    // Make the application a high priority application
    CEikonEnv::Static()->RootWin().EnableReceiptOfFocus( ETrue );
    CEikonEnv::Static()->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);


    }

    CSymbian1AppUi::CSymbian1AppUi()
    {
    // no implementation required
    }

    CSymbian1AppUi::~CSymbian1AppUi()
    {

    CEikonEnv::Static()->RootWin().CancelCaptureKeyUpAndDowns(iHashKeyHandle);

    if (iAppView)
    {
    iEikonEnv->RemoveFromStack(iAppView);
    delete iAppView;
    iAppView = NULL;
    }
    }

    //this function causes this app to stay in foreground even if i open another app.
    //void CSymbian1AppUi::HandleForegroundEventL (TBool aForeground)
    //{
    //// Make the application a high priority application
    //if (aForeground)
    //{
    //CEikonEnv::Static()->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
    //}
    //}

    // Handle Key Events in this
    void CSymbian1AppUi::HandleWsEventL (const TWsEvent &aEvent, CCoeControl *aDestination)
    {
    if (aEvent.Type() == EEventKey)
    {
    // This is for switching back to Application when Hash key is pressed
    if (EStdKeyHash == aEvent.Key()->iScanCode && EEventKey == aEvent.Type())
    {
    TApaTask task(iEikonEnv->WsSession());
    task.SetWgId(CEikonEnv::Static()->RootWin().Identifier());
    task.BringToForeground();
    return;
    }
    }
    CEikAppUi::HandleWsEventL(aEvent, aDestination);

    }

  4. #4

  5. #5
    Registered User vikhyath's Avatar
    Join Date
    Oct 2006
    Posts
    24
    Symbian 7.0S - Series 80. I am also testing on a Nokia 9500 phone.

    THanks,

    Vik

  6. #6
    Nokia Developer Champion xhsoldier's Avatar
    Join Date
    May 2006
    Location
    Beijing,China
    Posts
    1,190
    Only focus windows or apps has the ability to receive the keyevent.

    but for hot key event, it can be received even if your app is not on focus.
    I think,

  7. #7
    Registered User vin2ktalks's Avatar
    Join Date
    Jul 2005
    Location
    Bengaluru, India
    Posts
    747
    Quote Originally Posted by vikhyath
    Symbian 7.0S - Series 80. I am also testing on a Nokia 9500 phone.

    THanks,

    Vik
    I my self tested the above given link's code with 3rd Ed and 2.6, 2.8 version of SDK and was working fine. I never try with 2.0.

  8. #8
    Registered User vikhyath's Avatar
    Join Date
    Oct 2006
    Posts
    24
    The only line that changed was
    CEikAppUi::HandleWsEventL(aEvent, aDestination);

    in your version it was CAknAppUi.... Other than that all the functions are supported.....

    Is there any other way of ensuring hte application picks up keypresses?

    Thanks,

    Vik

  9. #9
    Registered User vin2ktalks's Avatar
    Join Date
    Jul 2005
    Location
    Bengaluru, India
    Posts
    747
    Check these API's with SDK RWindowGroup::CaptureKey(), RWindowGroup::CancelCaptureKey. And here you've an example of the same.

Similar Threads

  1. Handling key pressed events
    By yuava in forum Mobile Java General
    Replies: 8
    Last Post: 2011-07-08, 08:35
  2. Handling Key Events with TApaTask
    By MananW in forum Symbian C++
    Replies: 3
    Last Post: 2006-09-04, 08:52
  3. Replies: 3
    Last Post: 2006-08-30, 08:37
  4. Opening application and handling key events
    By kawaiimomo in forum Python
    Replies: 3
    Last Post: 2005-11-11, 05:11
  5. handling key events
    By metebalci in forum Mobile Java General
    Replies: 1
    Last Post: 2005-05-16, 10:46

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved