Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User ravi.joshi53's Avatar
    Join Date
    Jan 2011
    Location
    The Heart of India
    Posts
    41
    I am trying to develop cursor in my midlet application. i have already add cursor using drawImage() method. now i want to move it using navigation keys up down left and right... I developed this code:

    void keyPressed(int keyCode){
    int key=keyCode;
    switch(key){
    case -1: // to move up the cursor
    cursorY--;
    repaint();
    break;
    case -2: // to move down the cursor
    cursorY++;
    repaint();
    break;
    case -1: // to move left the cursor
    cursorX--;
    repaint();
    break;
    case -1: // to move right the cursor
    cursorX++;
    repaint();
    break;
    default:
    repaint();
    break;
    }
    this code is working properly but the only one problem is that to move the cursor from top to bottom, i have to press down key so many times..... I need any dragging concept to move the cursor.... i mean once i keep pressed a key for some time, cursor moves continue. In the above program, to move cursor, one has to keep press and unpressed the key continue.

    The method pointerPressed(int x,int y) is unsupported by all series 40 devices, so how to develop our own same method using existing API.

  2. #2
    Nokia Developer Champion raj_J2ME's Avatar
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,314
    Don't start the different threads for the same point/issues, already you have started this thread.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Registered User ravi.joshi53's Avatar
    Join Date
    Jan 2011
    Location
    The Heart of India
    Posts
    41
    ya, i know that... but i don't wanna disturb you.... i can you please help me......

  4. #4
    Nokia Developer Champion im2amit's Avatar
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    2,903
    this code is working properly but the only one problem is that to move the cursor from top to bottom, i have to press down key so many times..... I need any dragging concept to move the cursor.... i mean once i keep pressed a key for some time, cursor moves continue. In the above program, to move cursor, one has to keep press and unpressed the key continue.
    You can do it using - keyRepeated() and pointerPressed(int x,int y) is not needed for this.

    OR

    You can do this by starting a loop that keep's on repeating the Cursor movement i.e. (cursorY-- / cursorY++/cursorX++/cursorX--) & calling repaint() in in your keyPressed() method till keyRelease() is not called, by using a global boolean variable repeat.
    try

    Code:
     
    // declare a call level boolean variable repeat at the start of your class
    
    void keyPressed(int keyCode){
    int key=keyCode;
    repeat= true;
    do while(repeat){
    switch(key){
    case -1: // to move up the cursor 
    cursorY--;
    repaint();
    break;
    case -2: // to move down the cursor 
    cursorY++;
    repaint();
    break;
    case -1: // to move left the cursor 
    cursorX--;
    repaint();
    break;
    case -1: // to move right the cursor 
    cursorX++;
    repaint();
    break;
    default:
    repaint();
    break;
    }
    void keyReleased(int keyCode)
    {
     repeat = false;
    }
    thanks,
    ~Amitabh
    (Poster of the Month -Dec'12)
    Follow me on my blog for Innovative Mobile Apps

  5. #5
    Registered User ravi.joshi53's Avatar
    Join Date
    Jan 2011
    Location
    The Heart of India
    Posts
    41
    thank you amitabh..... thank you very much...

Similar Threads

  1. SDK for Series 40 5th Edition LE?
    By tqvisten in forum Mobile Java Tools & SDKs
    Replies: 6
    Last Post: 2009-06-25, 12:48
  2. Int и signed Int обмен данными между ними
    By Clever brain in forum Russian Developer Forum - Форум Российских разработчиков
    Replies: 2
    Last Post: 2009-05-11, 21:35
  3. series 40 5th Edition - Nokia Model 6500
    By sidsood in forum Mobile Java General
    Replies: 3
    Last Post: 2008-12-23, 16:54
  4. createImage(byte[],int,int) bug on Nokia 7650
    By bachin in forum Mobile Java General
    Replies: 3
    Last Post: 2005-09-16, 03:49
  5. 请教createImage(byte[] imageData, int imageOffset, int imageLength) 的问题
    By RongJia in forum [Archived] Other Programming Discussion 关于其他编程技术的讨论
    Replies: 5
    Last Post: 2005-03-27, 17:18

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved