×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    8

    Problem with keyPressed in Canvas

    I try to use method of keyPressed

    protected void keyPressed(int keyCode) {
    }

    I find "NUM2" and " UP" binded " NUM4"and "LEFT" binded

    when I press the "NUM2" and it will generate two keyCode "NUM2" and " UP"

    How can i separate them?

    thank you!

  2. #2
    Registered User
    Join Date
    Mar 2006
    Posts
    10

    Re: Problem with keyPressed in Canvas

    jhd

    hi jy820314

    this is becuaze in the case of keyPressed whenever u r pressing the key it is for both game as well text item.

    so what u do is before decodeing u just call funcation getGameAction(keycode) it will return
    Canvas.FIRE, Canvas.LEFT,Canvas.Right.........

    so u can compare this one to prevent from returning two values.

    Regards,
    Jasmit vala
    rajputjasmit@yahoo.co.in
    [FONT=Courier New][SIZE=7]JHD[/SIZE][/FONT]

  3. #3
    Registered User
    Join Date
    Dec 2010
    Location
    Delhi, India
    Posts
    7

    Re: Problem with keyPressed in Canvas

    I was using

    protected void keyPressed (int keyCode)
    {
    if(getGameAction(keyCode) == Canvas.FI(RE
    {
    //fire action
    }
    }

    to detect the selection or fire event. But when tested on phone, the FIRE event did not work

    so i used the following code

    int fireKey = getKeycode(Canvas.FIRE);
    int upKey = getKeyCode(Canvas.UP);
    int downKey = getKeyCode(Canvas.DOWN);

    protected void keyPressed (int keyCode)
    {
    if(keyCode == fireKey)
    {
    //fire action
    }
    else if (keyCode == upKey)
    {
    //up action
    }
    }

    can somebody tell what the problem is?

  4. #4
    Nokia Developer Expert
    Join Date
    Aug 2007
    Posts
    1,595

    Re: Problem with keyPressed in Canvas

    Hello bhanuj,

    are you testing the FIRE key when the Canvas is on full-screen mode?

    Regards,
    r2j7
    [URL="http://library.forum.nokia.com/java"][B] >>> Java Developer's Library <<<[/B][/URL]
    [URL="https://www.developer.nokia.com/Resources/Support/Technical_support.xhtml"] [B]>>> Technical Support for Java ME development <<<[/B][/URL]
    [URL="https://publish.ovi.com/info/"][B]>>> Nokia Publish: reach millions of Nokia users worldwide through Nokia Store <<<[/B][/URL]

Similar Threads

  1. Problem with J2ME canvas in Nokia N90
    By hepals in forum Mobile Java General
    Replies: 5
    Last Post: 2006-05-09, 01:07
  2. Replies: 2
    Last Post: 2005-09-15, 12:54
  3. About 6230 Bt Problem
    By eerkek in forum Bluetooth Technology
    Replies: 17
    Last Post: 2005-02-08, 12:33
  4. problem scrolling canvas
    By diplm in forum Mobile Java General
    Replies: 9
    Last Post: 2004-05-26, 21:19
  5. 7650 and 3650 Canvas and FullCanvas memory
    By marcilgen in forum Mobile Java General
    Replies: 5
    Last Post: 2003-07-08, 12:24

Posting Permissions

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