×

Discussion Board

Results 1 to 1 of 1
  1. #1
    Regular Contributor
    Join Date
    Apr 2003
    Location
    China P.R.
    Posts
    210

    System wide hotkey with modifier problem

    Greetings, friends and experts:
    This time, the problem is about key event and handling.

    My program is running background, and at ConstructL function of AppUi, i set a hotkey in system level by this
    Code:
    CaptureKeyUpAndDowns(HOTKEY_VALUE, 0, 0);
    and then my background application could capture EEventKeyDown and EEventKeyUp. but whats further i wanna do is to capture hotkey with modifier, such as the user presses EditKey[aka ABC_Key] and "#" at the same time.

    For doing this, in the HandleKeyEventL function of my AppUi, i set the condition
    Code:
    if (aType==EEventKeyUp && aKey.iModifier==KEditKeyModiferValue)  
    //Where "KEditKeyModiferValue" is defined by myself, 
    and i don't know whether the value is correct so i use macro here.
    This works well too, however, then comes the problem. After pressing the two keys at the same time, my HandleKeyEventL works. But when return to other application, e.g. Phone the very basic one, other applications can not handle keys for the reason that it seems EditKey hasn't been released. That means after my application's getting modifier key [i think only EditKey could be the modifier cause "Series60 UI style guide" said so] of a system level key event, the following events passed away, not going to other applications. After my pressing EditKey for one time, all things return normal.

    This is not so curious i think because i haven't used the second and third paramters in CaptureKey() function. the description of this function in DeveloperLibrary from Symbian is rather messy, and i even dare to use some enumeration in that two parameters to test which case could satisfy me....

    Finnaly i paste that here, hope any master who could understand this could give me some solution.

    /************************************************
    CaptureKey()
    TInt32 CaptureKey(TUint aKeycode, TUint aModifierMask, TUint aModifier);
    Description
    Requests key capture.

    Use this function to instruct the window server to send key events (of type EEventKey) from the specified key to this window group, regardless of which window group currently has the keyboard focus.

    Key events for the key given by aKeyCode are captured only when the modifier keys specified by aModifierMask are in the states specified by aModifier. See RWsSession::SetHotKey() for examples of how to use aModifierMask and aModifier.

    Normally, keyboard key presses result in three events being delivered to the client: EEventKeyDown, EEventKey and EEventKeyUp. However, CaptureKey() results in only the EEventKey being delivered to the window group that called it: the EEventKeyUp and EEventKeyDown events are sent to the window group that has focus. If a window group wishes to capture the EEventKeyUp and EEventKeyDown events as well as the EEventKey, it should call CaptureKeyUpAndDowns().

    Parameters
    TUint aKeycode The key code for the key to be captured. Key codes for special keys are defined in TKeyCode.

    TUint aModifierMask Only the modifier keys in this mask are tested against the states specified in aModifier.

    TUint aModifier The key is captured only when the modifier keys specified in aModifierMask match these states, where 1=modifier set, and 0=modifier not set. Modifier key states are defined in TEventModifier.



    Return value
    TInt32 A handle identifying the capture key, or one of the system-wide error codes (if <0). Handles should be kept in order to be passed to CancelCaptureKey() later.

    *************************************************/

    Thanks in advance...
    Regards

    kcome
    Last edited by kcome; 2003-11-14 at 02: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
  •  
×