×

Discussion Board

Page 1 of 3 123 LastLast
Results 1 to 15 of 31
  1. #1
    Regular Contributor
    Join Date
    Jun 2010
    Posts
    107

    Exclamation Please Solve this key capture

    hi,
    i want to handle keyevents while application running in background. but i am unable to do it.
    i written this code


    TKeyResponse CDemoUI1AppView::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
    {

    if ( aKeyEvent.iCode== '#' )
    {

    iEikonEnv->AlertWin (_L("keycaptured"));
    return EKeyWasConsumed;
    }

    return EKeyWasNotConsumed;

    }

    and draw() method i added this code

    CEikonEnv::Static()->RootWin().CaptureKey('#' , 0 , 0);

    but nothing is happen. do i need to add any other code to this?

    To make application to run in background i used

    RWsSession aWsSession;
    aWsSession.Connect();
    TApaTask task(aWsSession);
    task.SetWgId( CEikonEnv::Static()->RootWin().Identifier());
    task.SendToBackground();
    aWsSession.Close();

    Application is going background but when i press # key no dialog box is coming.

    pls help me.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,673

    Re: Please Solve this key capture

    I would not bet on OfferKeyEventL, since your application is in the background. Check AppUi::HandleKeyEventL, or even AppUi::HandleWsEventL directly.

  3. #3
    Regular Contributor
    Join Date
    Jun 2010
    Posts
    107

    Re: Please Solve this key capture

    Thanks . Its Working now with HandleWsEventL.
    but that key is freezed. i.e. i used key '1' to display dialog box. But in main screen when i press numbers all numbers are displaying but for key '1' it is displaying dialog box wat i mentioned in applicaiton.

    I need key '1' also should work like remaining keys.

    pls wat i can do for it?

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,673

    Re: Please Solve this key capture

    If you search for capturekey in the Wiki, you will find
    Code:
    TInt wgId = iWsSession.GetFocusWindowGroup();
    iWsSession.SendEventToWindowGroup( wgId, e );
    those two lines are about forwarding the keypress to the focused application.

  5. #5
    Regular Contributor
    Join Date
    Jun 2010
    Posts
    107

    Re: Please Solve this key capture

    Thank you, but i am not sure exactly where to keep this code in my application. In the given forum example they used seperate class, and in that RunL() method they used this code.
    In my code can i keep this in HandleWsEventL().
    one more doubt if this code gets focused to the current application means then how abt my application. Will my application can still listen this and log this key?
    Actually i need that ,My application should run in background and wat ever the key press is done it should be captured and stored in a log file .

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,673

    Re: Please Solve this key capture

    Quote Originally Posted by sridharbandi View Post
    Thank you, but i am not sure exactly where to keep this code in my application. In the given forum example they used seperate class, and in that RunL() method they used this code.
    In my code can i keep this in HandleWsEventL().
    There is no difference, these are variables and method calls, they do not care about where you are calling them. Also note that HandleWsEventL is actually invoked by CCoeEnv::RunL - in Symbian every asynchronous callback has an active object somewhere in the background.
    one more doubt if this code gets focused to the current application means then how abt my application. Will my application can still listen this and log this key?
    These two lines do not affect capturing keys, they just show how to send an event to the currently focused window group.

  7. #7
    Regular Contributor
    Join Date
    Aug 2009
    Posts
    128

    Re: Please Solve this key capture

    I am facing the same issue but I am not quite clear how CaptureKey('#',0,0) is helping you out?
    As it will only capture the "#" key, how your application is getting all keys for logging??

  8. #8
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,673

    Re: Please Solve this key capture

    You have to issue CaptureKey for all keys, one by one.

  9. #9
    Regular Contributor
    Join Date
    Aug 2009
    Posts
    128

    Re: Please Solve this key capture

    thanks .. It works but I want to system menu to stop responding to captured keys(like left/right soft keys) ..
    Currently, by capturing those key my application gets those keys along with the system menu.
    Eventually, I want my own menu to be function at idle screen rather than system menu.

  10. #10
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Please Solve this key capture

    Quote Originally Posted by sumit.ece View Post
    ... Eventually, I want my own menu to be function at idle screen rather than system menu.
    what you are trying to do, might be there is a easier way out .

  11. #11
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,673

    Re: Please Solve this key capture

    If you read the original discussion with Sridharbandi, you will see that the default behaviour is that your application gets the captured keypresses, and the focused application does not. Now if that is what you want, you are ready (note that such application may have problems with passing the Symbian Signed test criteria).

  12. #12
    Regular Contributor
    Join Date
    Aug 2009
    Posts
    128

    Re: Please Solve this key capture

    Hi skumar,
    i want to display my content (basically draw) and my menu on idle screen and wanted them to respond to key events (mainly soft keys).
    Right now, i am displaying menu using my draw method.

    I am able to draw to idle screen using following thread.
    "http://wiki.forum.nokia.com/index.php/How_to_display_ticker_on_active_idle"
    Now, to respond to soft key events, i tried to capture keys with scan code 164,165. My application capture it but system captures it as well.

    Is there any alternative to this approach??

  13. #13
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Please Solve this key capture

    yes i guessed so, long back i have tried it with out any result, might be this will try again, this time might get a work around.

  14. #14
    Regular Contributor
    Join Date
    Aug 2009
    Posts
    128

    Re: Please Solve this key capture

    @wizard - my application gets captured key presses but idle screen also (not any other focused application) gets those key presses for soft keys. I want only my content to be updated on menu press.

  15. #15
    Regular Contributor
    Join Date
    Jun 2010
    Posts
    107

    Re: Please Solve this key capture

    oh.... for all all numbers and alphabets do we have to include this type of code CEikonEnv::Static()->RootWin().CaptureKey('#' , 0 , 0); ?
    and
    i used RunL() in my appview
    void CDemoUI1AppUi::RunL()
    {
    TWsEvent e;
    iWsSession.GetEvent(e);

    TInt wgId = iWsSession.GetFocusWindowGroup();
    iWsSession.SendEventToWindowGroup(wgId, e);

    }

    but its not responding.

    i tried adding

    TInt wgId = iWsSession.GetFocusWindowGroup();
    iWsSession.SendEventToWindowGroup(wgId, e);

    to my HandleWsEventL() method to get the focus to current application . but it is invain and emulator is closing automatically if i run this.

    could you please suggest me where i can i keep this code in myapp to get focus to current application

Similar Threads

  1. capture short key and long key
    By kkrish in forum Symbian
    Replies: 4
    Last Post: 2010-02-09, 04:48
  2. Capture # key
    By NRK in forum Symbian
    Replies: 11
    Last Post: 2009-09-29, 08:21
  3. Is it possible to capture hard keys (calendar key, contacts key etc.)
    By liszka170 in forum Symbian User Interface
    Replies: 3
    Last Post: 2009-06-22, 11:19
  4. Key capture
    By 1xuname1x in forum Symbian
    Replies: 2
    Last Post: 2009-05-21, 09:50
  5. How to capture key press and key release events in series 60 for 7650?
    By varshajohn in forum Symbian User Interface
    Replies: 2
    Last Post: 2003-04-30, 13:03

Posting Permissions

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