• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Canvas direct text input (TextBox alternative)

 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Surprisingly little info on this on the net, so wonder if anyone can help:

Rather than opening a native javax.microedition.lcdui.TextBox, I want to be able to detect user input directly on a canvas (with the keyPressed() method).

I'm creating a generic MIDP2 midlet, and the main problem I'm going to face is detecting when the user has entered a space (as it could be possibly, the '0' key, the '#' key, the '*' key or the '1' key).

Is the best solution to just treat any of those key presses as a space, or is there a better way? Has anyone already got the code?

Cheers,
James
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you taken a look at the TWUIK? It looks impressive.

http://www.tricastmedia.com/twuik/

http://youtube.com/watch?v=2M3GYhMSxrU

I use a pure canvas text entry component for most of my applications. In most cases I mimic multi-tap functionality. For example, the key '0' is mapped to ' ' and '0' Pressing 0 once is treated as a space, and pressing it two times is considered 0.

Likewise, '#' and '*' are reserved for "#$[]{}~^`|" and "*-_()/\\:;+&%*=<>$" respectively.

I know which character to choose by the number of times the key was pressed. I have an external text file that can customize the mappings for different phones. For example, my E61 has a QWERTY layout and uses a key map file that takes advantage of it.

You can grab my source code from hostj2me.com from any of the applications below. The interesting classes are TextInputEngine, TextInputListener, and ~TextInputWidget.

http://hostj2me.com/appdetails.html?id=2519
http://hostj2me.com/appdetails.html?id=1557
http://hostj2me.com/appdetails.html?id=1569

Here are some videos of applications which use the text entry component.

http://worlddeveloper.org/files/1877/yipi.wmv
http://worlddeveloper.org/files/3799/demo1.wmv
http://worlddeveloper.org/files/4054/meos.wmv

Two final considerations are mapping the delete key and how to select uppercase characters...
 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Rashid,

TWUIK looks nice but a bit a overkill for my needs, but I'll check your source code out.

Like I mentioned though, I'm creating a generic midp 2.0 midlet and I don't really want the hassle of having to update a mappings text file when new phone models are released, etc.

So with that being the case, I suppose the only way for me to reliably detect the user pressing his SPACE character key, would be to treat buttons 1, *, 0, # and RIGHT as spaces (and ignoring special characters - which I don't need anyway).

But QWERTY keyboards throw a spanner into the works... (Presumably, they're not detectable in MIDP2?)

Maybe what I'm looking to achieve isn't possible...
[ June 29, 2007: Message edited by: James Hodgkiss ]
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
pl. help how to use keylistener.iam using blackberry.from the api document i got some info.

Keypad.key(int keycode) gets the key pressed
Using Keypad.status(int keycode) gets the modifier key status at the time of the keypress.
net.rim.device.api.system.KeyListener.keyDown()
is invoked when a key has been pressed.

but how to get the keycode value?because i don't know which key the user will press.i want to trigger eventlistener when any of the keys on the keypad is pressed by user.iam not finding method something like getkeychar() ...

Regards
 
Think of how dumb the average person is. Mathematically, half of them are EVEN DUMBER. Smart tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic