• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

working on celphone's keypad

 
Benjoe Reyes
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i need a sample program which would show what source of the event a listener would listen to if i pressed a key like "5"... like that i am trying to make an sms on ther phone.
thanks...
 
Christian Wolf
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just saw your post. Maybe you have already found the answer because you looked for the Canvas. Only the Canvas class (or GameCanvas on MIDP 2.0) offers low level access to the keys. You have to make a child from Canvas that implements following method:

BTW, the complete MIDP 1.0+2.0 documentation is also included
in the Sun Wireless Toolkit in the docs folder.
Christian Wolf
 
Benjoe Reyes
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well gaming is a different thing from texting sms. it might look that i'm trying to "reinvent the wheel" but i would like to see how repeatedly pressing a key produced a particular letter.
i'm not happy with my cp's "behavior" when i'm texting. so i'm thinking of making it do what i want. hehehehe
 
Christian Wolf
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you want to reinvent the TextField functionality? You seem to have a lot of time. *g*
Sure, Canvas is made ALSO for gaming but you can, of course, use it for serious issues, too. It is not too difficult to have a specific charset available (latin letters, numbers, and so on) and process the pressed keys in the way you want. You could even implement a kind of T9 (word prediction) if you want to. *g*
Christian Wolf
 
Benjoe Reyes
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
then keyPressed() is the key method for it and i would just add a counter so repeated pressing would produce different letters. my only problem is the timeout function when it happens it finalizes the letter displayed... and a lot of switch blocks...
i am thinking of having the timeout function as a different thread and have it reset everytime a key is pressed...
is my hypothesis correct???
 
Christian Wolf
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
then keyPressed() is the key method for it and i would just add a counter so repeated pressing would produce different letters. my only problem is the timeout function when it happens it finalizes the letter displayed... and a lot of switch blocks...

Correct. keyPressed() is the method you need to use. You don't need to use another Thread. Just use the Timer class and TimerTask (which itself is a thread implementation) and then just schedule a new task on each keypress.

Take care to cancel the scheduled task when user presses a key prior than the 500 milliseconds with using timer.cancel().
Christian Wolf
 
Benjoe Reyes
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks christian
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic