×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    311

    about Capturing keys in background.

    I use the wiki example "Capturing keys in background".
    To capturing the rightsoft key.

    my app runing in background all time. when I capturing the rightsoft key(EKeyDevice1). I want show a
    floatingwindow. the floating window is half size of screen. when I capture the key event
    the floating window can show right. but the problem is that the ForegroundL App excute the keys event also.

    how to solve it ? thanks .

  2. #2
    Super Contributor
    Join Date
    Jun 2006
    Location
    India
    Posts
    3,037

    Re: about Capturing keys in background.

    Do not send the key to other windows, consume the key at your application level.
    Use [URL="http://qt.nokia.com/products/qt-quick/"]Qt-Quick[/URL] to make your application UI more attractive.

    [URL="http://store.ovi.com/content/271896"]http://store.ovi.com/content/271896[/URL] | [URL="http://store.ovi.com/content/276199"]http://store.ovi.com/content/276199[/URL] |[URL="http://store.ovi.com/content/276202"] http://store.ovi.com/content/276202[/URL] | [URL="http://store.ovi.com/content/280827"]http://store.ovi.com/content/280827[/URL]

  3. #3
    Registered User
    Join Date
    Aug 2007
    Posts
    311

    Re: about Capturing keys in background.

    Quote Originally Posted by kkrish View Post
    Do not send the key to other windows, consume the key at your application level.
    if(iObserver.KeyCapturedL(e))
    {
    TInt wgId = iWsSession.GetFocusWindowGroup();
    iWsSession.SendEventToWindowGroup(wgId, e);
    }
    in my app the line iWsSession.SendEventToWindowGroup(wgId, e); was excute.

  4. #4
    Registered User
    Join Date
    Aug 2007
    Posts
    311

    Re: about Capturing keys in background.

    void CKeyCapturer::RunL()
    {
    if (iStatus == KErrNone)
    {
    TWsEvent e;
    iWsSession.GetEvent(e);
    if(iObserver.KeyCapturedL(e))
    {
    TInt wgId = iWsSession.GetFocusWindowGroup();
    iWsSession.SendEventToWindowGroup(wgId, e);
    }
    }
    if (iStatus != KErrCancel)
    {
    Listen();
    }
    }

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,737

    Re: about Capturing keys in background.

    I do not see what you expect from SendEventToWindowGroup. It sends the event to a window group. Then it is slightly pointless to complain about that the window group is getting the event...
    "Focus window group" = "the other application" in this case.

  6. #6
    Registered User
    Join Date
    Aug 2007
    Posts
    311

    Re: about Capturing keys in background.

    Quote Originally Posted by wizard_hu_ View Post
    I do not see what you expect from SendEventToWindowGroup. It sends the event to a window group. Then it is slightly pointless to complain about that the window group is getting the event...
    "Focus window group" = "the other application" in this case.
    HI, wizar_hu_
    you mean Session.SendEventToWindowGroup(wgId, e);
    send the key event to the ForegroundL App ?
    but I comment out the

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

    it has the same result.

  7. #7
    Registered User
    Join Date
    Aug 2007
    Posts
    311

    Re: about Capturing keys in background.

    MY Code follow:
    KeyCapturer.h:

    class MKeyCallBack
    {
    public:
    virtual TBool KeyCapturedL(TWsEvent aEvent) = 0;
    };

    class CKeyCapturer: public CActive
    {
    public:

    static CKeyCapturer* NewL(MKeyCallBack& aObserver);
    static CKeyCapturer* NewLC(MKeyCallBack& aObserver);
    virtual ~CKeyCapturer();

    public:

    void Listen();

    private:
    CKeyCapturer(MKeyCallBack& aObserver);
    void ConstructL();
    void RunL();
    void DoCancel();


    private:

    MKeyCallBack& iObserver;
    RWsSession iWsSession;
    RWindowGroup iWg;
    TInt iHandle;
    };

    KeyCapturer.cpp:

    #include "KeyCapturer.h"

    CKeyCapturer* CKeyCapturer::NewL(MKeyCallBack& aObserver)
    {
    CKeyCapturer* self = CKeyCapturer::NewLC(aObserver);
    CleanupStack::Pop(self);
    return self;
    }

    CKeyCapturer* CKeyCapturer::NewLC(MKeyCallBack& aObserver)
    {
    CKeyCapturer* self = new (ELeave) CKeyCapturer(aObserver);
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
    }

    CKeyCapturer::CKeyCapturer(MKeyCallBack& aObserver):CActive(EPriorityStandard),iObserver(aObserver),iHandle(-1)
    {
    }


    CKeyCapturer::~CKeyCapturer()
    {
    if(iHandle > -1)
    {
    iWg.CancelCaptureKey(iHandle);
    }

    iHandle = -1;
    Cancel();
    iWg.Close();
    iWsSession.Close();
    }

    void CKeyCapturer::ConstructL()
    {
    CActiveScheduler::Add(this);
    User::LeaveIfError(iWsSession.Connect());
    iWg=RWindowGroup(iWsSession);
    User::LeaveIfError(iWg.Construct((TUint32)&iWg, EFalse));
    iWg.SetOrdinalPosition(-1);
    iWg.EnableReceiptOfFocus(EFalse);
    CApaWindowGroupName* wn=CApaWindowGroupName::NewLC(iWsSession);
    wn->SetHidden(ETrue);
    wn->SetWindowGroupName(iWg);
    CleanupStack::PopAndDestroy();
    iHandle = iWg.CaptureKey(EKeyDevice1, 0,0);
    Listen();
    }

    void CKeyCapturer::RunL()
    {
    if (iStatus == KErrNone)
    {
    TWsEvent e;
    iWsSession.GetEvent(e);
    if(iObserver.KeyCapturedL(e))
    {
    TInt wgId = iWsSession.GetFocusWindowGroup();
    iWsSession.SendEventToWindowGroup(wgId, e);
    }
    }
    if (iStatus != KErrCancel)
    {
    Listen();
    }
    }

    void CKeyCapturer:oCancel()
    {
    iWsSession.EventReadyCancel();
    }

    void CKeyCapturer::Listen()
    {
    iWsSession.EventReady(&iStatus);
    SetActive();
    }

  8. #8
    Registered User
    Join Date
    Aug 2007
    Posts
    311

    Re: about Capturing keys in background.

    the APPUI code :
    1.开机自启动。
    2。隐藏程序列表,隐藏应用程序图标。
    3。挂机后始终有确认按钮,确认后程序跳到号码簿
    4。除第一次外,其它USSD都为系统原始USSD显示窗口

    /*
    ============================================================================
    Name : TestKeyCaptureAppUi.cpp
    Author : ghm
    Copyright : Your copyright notice
    Description : CTestKeyCaptureAppUi implementation
    ============================================================================
    */

    // INCLUDE FILES
    #include <avkon.hrh>
    #include <aknmessagequerydialog.h>
    #include <aknnotewrappers.h>
    #include <stringloader.h>
    #include <f32file.h>
    #include <s32file.h>
    #include <hlplch.h>

    #include <TestKeyCapture_0xE0511839.rsg>

    #ifdef _HELP_AVAILABLE_
    #include "TestKeyCapture_0xE0511839.hlp.hrh"
    #endif
    #include "TestKeyCapture.hrh"
    #include "TestKeyCapture.pan"
    #include "TestKeyCaptureApplication.h"
    #include "TestKeyCaptureAppUi.h"
    #include "TestKeyCaptureAppView.h"

    #include "FloatingWindow.h"



    // ============================ MEMBER FUNCTIONS ===============================

    TInt KeyCapturerCallBack(TAny *aPtr)
    {
    CTestKeyCaptureAppUi* appUI = (CTestKeyCaptureAppUi*) aPtr;
    appUI->iKeyCapturerTimer->Cancel();
    delete appUI->iCapturer;
    appUI->iCapturer = NULL;
    return 0;
    }

    // -----------------------------------------------------------------------------
    // CTestKeyCaptureAppUi::ConstructL()
    // Symbian 2nd phase constructor can leave.
    // -----------------------------------------------------------------------------
    //
    void CTestKeyCaptureAppUi::ConstructL()
    {
    // Initialise app UI with standard value.
    BaseConstructL(CAknAppUi::EAknEnableSkin);

    // Create view object
    iAppView = CTestKeyCaptureAppView::NewL(ClientRect());

    iFloatingWindow = CFloatingWindow::NewL();
    iCallObserver = CMyCallObserver::NewL(*this);
    iKeyCapturerTimer = CPeriodic::New(CActive::EPriorityStandard);

    if(iCapturer)
    {
    delete iCapturer;
    }
    iCapturer = CKeyCapturer::NewL(*this);

    }
    // -----------------------------------------------------------------------------
    // CTestKeyCaptureAppUi::CTestKeyCaptureAppUi()
    // C++ default constructor can NOT contain any code, that might leave.
    // -----------------------------------------------------------------------------
    //
    CTestKeyCaptureAppUi::CTestKeyCaptureAppUi()
    {
    // No implementation required
    }

    // -----------------------------------------------------------------------------
    // CTestKeyCaptureAppUi::~CTestKeyCaptureAppUi()
    // Destructor.
    // -----------------------------------------------------------------------------
    //
    CTestKeyCaptureAppUi::~CTestKeyCaptureAppUi()
    {
    if (iAppView)
    {
    delete iAppView;
    iAppView = NULL;
    }

    delete iFloatingWindow;
    delete iKeyCapturerTimer;
    }

    // -----------------------------------------------------------------------------
    // CTestKeyCaptureAppUi::HandleCommandL()
    // Takes care of command handling.
    // -----------------------------------------------------------------------------
    //
    void CTestKeyCaptureAppUi::HandleCommandL(TInt aCommand)
    {
    switch (aCommand)
    {
    case EEikCmdExit:
    // case EAknSoftkeyExit:
    Exit();
    break;

    case ECommand1:
    {
    iFloatingWindow->iShowType = 1;
    iFloatingWindow->DisplayL();
    iFloatingWindow->BringToForegroundL();
    }
    break;

    default:
    // Panic( ETestKeyCaptureUi);
    break;
    }
    }
    // -----------------------------------------------------------------------------
    // Called by the framework when the application status pane
    // size is changed. Passes the new client rectangle to the
    // AppView
    // -----------------------------------------------------------------------------
    //
    void CTestKeyCaptureAppUi::HandleStatusPaneSizeChange()
    {
    iAppView->SetRect(ClientRect());
    }

    CArrayFix<TCoeHelpContext>* CTestKeyCaptureAppUi::HelpContextL() const
    {
    #warning "Please see comment about help and UID3..."
    // Note: Help will not work if the application uid3 is not in the
    // protected range. The default uid3 range for projects created
    // from this template (0xE0000000 - 0xEFFFFFFF) are not in the protected range so that they
    // can be self signed and installed on the device during testing.
    // Once you get your official uid3 from Symbian Ltd. and find/replace
    // all occurrences of uid3 in your project, the context help will
    // work. Alternatively, a patch now exists for the versions of
    // HTML help compiler in SDKs and can be found here along with an FAQ:
    // http://www3.symbian.com/faq.nsf/AllB...2?OpenDocument
    #ifdef _HELP_AVAILABLE_
    CArrayFixFlat<TCoeHelpContext>* array = new(ELeave)CArrayFixFlat<TCoeHelpContext>(1);
    CleanupStack::PushL(array);
    array->AppendL(TCoeHelpContext(KUidTestKeyCaptureApp, KGeneral_Information));
    CleanupStack::Pop(array);
    return array;
    #else
    return NULL;
    #endif
    }



    TBool CTestKeyCaptureAppUi::KeyCapturedL(TWsEvent aEvent)
    {
    if(aEvent.Key()->iCode == EKeyDevice1)
    {
    iFloatingWindow->iShowType = 1;
    iFloatingWindow->DisplayL();
    iFloatingWindow->BringToForegroundL();
    iKeyCapturerTimer->Start(10000, 10000, TCallBack(KeyCapturerCallBack, (TAny*) this));
    return 1;
    }
    iKeyCapturerTimer->Start(10000, 10000, TCallBack(KeyCapturerCallBack, (TAny*) this));
    return 0;
    }

  9. #9
    Registered User
    Join Date
    Aug 2007
    Posts
    311

    how to consume the key event which capture by CKeyCapturer?

    Hi, all.
    in my app, when I capture the key event by the CKeyCapturer, I want consume the key event.

    but not in the way .
    TInt wgId = iWsSession.GetFocusWindowGroup();
    iWsSession.SendEventToWindowGroup(wgId, e);

    I want all app dot receive the key event . but the key event uwas consume, how to do that,

    thanks.

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

    Re: how to consume the key event which capture by CKeyCapturer?

    Basically when you capture key, and if you need somebody else to use it, then you need to also forward it. There is really no other way.

  11. #11
    Registered User
    Join Date
    Aug 2007
    Posts
    311

    Re: how to consume the key event which capture by CKeyCapturer?

    HI,symbianyucaa.
    when i capture a key event. if I don't do anythings.

    if the event go on consume by the focus app?

  12. #12
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,737

    Re: how to consume the key event which capture by CKeyCapturer?

    Merged with the old thread.

  13. #13
    Registered User
    Join Date
    Aug 2007
    Posts
    311

    Re: how to consume the key event which capture by CKeyCapturer?

    HI,

    when i capture the key event. do that
    Int wgId = iWsSession.GetFocusWindowGroup();
    iWsSession.SendEventToWindowGroup(wgId, e);
    the key event will sent to foreground App.
    can I send the key event to my app not the foreground App?

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

    Re: how to consume the key event which capture by CKeyCapturer?

    Why wouldn't you simply capture it in the app you want to use it ?

Similar Threads

  1. about CTelephony & CKeyCapturer
    By lmyuanhang in forum Symbian
    Replies: 2
    Last Post: 2012-06-20, 09:12
  2. Capture Key Event...
    By sanjayks84 in forum Symbian
    Replies: 6
    Last Post: 2009-10-28, 00:53
  3. How to capture mobile ringing event or call connected event
    By nitin.84india in forum Mobile Java General
    Replies: 4
    Last Post: 2009-09-03, 06:19
  4. Replies: 7
    Last Post: 2008-12-22, 13:00
  5. About Capture foreground key event.
    By yql in forum Symbian
    Replies: 2
    Last Post: 2007-11-02, 09:37

Posting Permissions

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