×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Nokia Developer Champion
    Join Date
    Sep 2007
    Posts
    915

    Events for up and down button

    I want to perform some action when user press up and down button. HOw can i handle the events regarding it ?

  2. #2
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    166

    Re: Events for up and down button

    In ur canvas you have to override the method


    protected void keyPressed(int keyCode) {
    switch(getGameAction(keyCode)){
    case Canvas.UP:
    //do something
    break;
    case Canvas.DOWN:
    //do something
    break;

    }
    }

  3. #3
    Nokia Developer Expert
    Join Date
    May 2007
    Location
    Mexico D.F
    Posts
    351

    Re: Events for up and down button

    honest_success

    please explain yourself a little bit more.
    :Ruben

  4. #4
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: Events for up and down button

    Hi,
    Honest are you talking about the up and down key pressed..
    You can move like this -
    protected void keyPressed(int keyCode)
    {
    if(keyCode == -1)
    {
    // Up key action ..you wana
    }
    else if(keyCode == -2)
    {
    // Down key action ..you wana
    }
    }

    As mahesh has suggested thats also a way to do that..However the getGameAction(keycode) has a tendency to give the incorrect results...sometimes..

    Thanks,
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  5. #5
    Nokia Developer Champion
    Join Date
    Sep 2007
    Posts
    915

    Re: Events for up and down button

    Quote Originally Posted by raj_J2ME View Post
    Hi,
    Honest are you talking about the up and down key pressed..
    You can move like this -
    protected void keyPressed(int keyCode)
    {
    if(keyCode == -1)
    {
    // Up key action ..you wana
    }
    else if(keyCode == -2)
    {
    // Down key action ..you wana
    }
    }

    As mahesh has suggested thats also a way to do that..However the getGameAction(keycode) has a tendency to give the incorrect results...sometimes..

    Thanks,
    Thanks i got your point.

Posting Permissions

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