2

I'm adding in some functionality to a MIDP-based app which requires me to track whether or not an Item has focus. I'm only really concerned with field-style Items and need to determine when the user has finished inputting data into the Item.

I'm aware that CustomItem has the traverse() callback, but I can't find anything similar for classes like DateField, TextField and ChoiceGroup.

I'm also aware of Display.setCurrentItem() but for some strange reason there doesn't seem to be a Display.getCurrentItem() method.

Implementing all the controls as CustomItems isn't really an option as it's a pre-existing app and there are quite a lot of controls to deal with. I can't believe that nobody has run into this issue before, but I've searched on here and google to no avail. Hopefully I'm just missing something obvious in the API, but if there isn't a definite answer then creative solutions are welcome!

gnat
  • 6,213
  • 108
  • 53
  • 73
vaughandroid
  • 4,315
  • 1
  • 27
  • 33
  • Why don't you use LWUIT ? LWUIT has a listener of focus gaining and focus losing ! – pheromix Nov 22 '11 at 12:23
  • @pheromix I haven't got any experience using LWUIT, but I assume it's not really an option for the same reason I don't want to re-implement all the controls as `CustomItems` - it's a pre-existing app that I'm just adding to. If LWUIT has simple wrappers for all the `Item` classes though I'll look into is... – vaughandroid Nov 22 '11 at 14:01

1 Answers1

0

In MIDP 2 lcdui API, the only field-style Items are, well, interactive subclasses of Item: TextField, DateField, Gauge.

For above items the closest match to what you are asking about seem to be provided by ItemStateListener (take a look at API javadocs here if you're interested).

...used by applications which need to receive events that indicate changes in the internal state of the interactive items...For implementations that have the concept of an input focus, the listener should be called no later than when the focus moves away from an item whose state has been changed.

  • If you plan to use this API, carefully check the docs to verify that it indeed gives you what you want - there are some subtle limitations there. If it turns out that you need greater control than that, your options are either to use low level UI (Canvas, events) or 3rd party library like LWUIT, J2ME Polish...
gnat
  • 6,213
  • 108
  • 53
  • 73
  • This matches what I found with my own investigations. Unfortunately, what I wanted to do just isn't possible with LCDUI without implementing custom controls using `CustomItem`. – vaughandroid Dec 01 '11 at 09:33