×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    26

    How to capture key event in console program?

    Hello.

    I make a console program.
    It works good in emulator.(input is 'a' key -> result is print screen)

    But, After I install console program in phone, execute the console program, and press any key then the console program exit.

    My question is
    How to catch the key event in console program?

    Give some direction to me.
    Thanks in advance.

  2. #2
    Registered User
    Join Date
    Jun 2006
    Posts
    259

    Re: How to capture key event in console program?

    Hi,

    Try with TKeyCode code =console->Getch();

    Cheer's

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    26

    Re: How to capture key event in console program?

    I already did like that.

    input = console->Getch();

    But, It's not working..

    How can I get a key event in console?

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,572

    Re: How to capture key event in console program?

    It is really bad for you, since CConsoleBase::Getch works for everybody else.

  5. #5
    Registered User
    Join Date
    Jun 2006
    Posts
    259

    Re: How to capture key event in console program?

    Hi Seera,

    Can you post the code you have written, it's easyer to find the mistakes. Some one in the forum will certainly helps you.

    Cheer's

  6. #6
    Registered User
    Join Date
    Sep 2006
    Posts
    26

    Re: How to capture key event in console program?

    Thanks all... ^^
    Here is.
    My program is
    if you execute the program, you can show the main menu.
    And press the 'a' key then you can show the submenu.

    It works good at emulator.
    But, when i execute the program in the phone(Nokia73),
    I can show the main menu. but if i press any key, just program exit.

    It based on Symian 3rd edition.

    ---------------------------------------------------------
    class CTestClass
    {
    public:
    CTestClass();
    ~CTestClass();

    static void test();
    };

    GLDEF_C TInt E32Main() // main function called by E32
    {
    __UHEAP_MARK;
    CTrapCleanup* cleanup=CTrapCleanup::New();
    TRAPD(error,callTestMainL()); // more initialization, then do example
    __ASSERT_ALWAYS(!error,User::Panic(KTxtEPOC32EX,error));
    delete cleanup; // destroy clean-up stack
    __UHEAP_MARKEND;
    return 0; // and return
    }


    void callTestMainL() // initialize and call example code under cleanup stack
    {

    console=Console::NewL(KTxtExampleCode,TSize
    (KConsFullScreen,KConsFullScreen));
    CleanupStack::PushL(console);
    TRAPD(error, CTestClass::test());
    if (error)
    console->Printf(KFormatFailed, error);
    else
    console->Printf(KTxtOK);
    User::After(3000000);
    CleanupStack::PopAndDestroy(); // close console
    }


    void CTestClass::test()
    {
    TKeyCode input ;

    do
    {
    displayMainMenu();
    input = console->Getch() ;

    console->SetPos(0);
    console->Printf(_L("Your Input = %c\n\n"), input);

    if ( input == 'a') //sub menu a
    {
    displaySubAMenu();
    doSubAMenu();

    }
    } while (input != EKeyEscape) ; //End DO

    }

Similar Threads

  1. not getting send (call or green) key event
    By vasant21 in forum Symbian
    Replies: 2
    Last Post: 2007-01-09, 17:31
  2. background program capture key input
    By jackxie in forum Mobile Java General
    Replies: 1
    Last Post: 2006-07-03, 16:26
  3. Replies: 8
    Last Post: 2003-07-11, 12:56
  4. Key Event Issues
    By mykes in forum Symbian
    Replies: 0
    Last Post: 2003-05-01, 10:55
  5. Key event not working in 7650 simulator
    By hillcast1 in forum Mobile Java General
    Replies: 1
    Last Post: 2002-12-15, 14:47

Posting Permissions

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