1

I initialized the VKBImplementationFactory in startApp() :

public void startApp() {
        VKBImplementationFactory.init();
        Display.init(this);
        new MenuPrincipalForm(this).show();
    }

I created also a VirtualKeyboard in a Form :

...
private VirtualKeyboard vkNombre = new VirtualKeyboard();
...
vkNombre.setInputModeOrder(new String[]{VirtualKeyboard.NUMBERS_SYMBOLS_MODE});

And I bound this VirtualKeyboard to a TextField :

cintxt=new TextField();
VirtualKeyboard.bindVirtualKeyboard(cintxt, vkNombre);

I registered dataChangeListener to this TextField :

public class ModifierFicheClient extends Form implements ActionListener, DataChangedListener 
{
  ...
  cintxt.addDataChangeListener(this);
  ...
}

In the dataChanged(int type, int index) method I want to open the vkNombre VirtualKeyBoard. I know that when clicking the TextField then the VirtualKeyboard is shown automatically. But there is a case when navigating to the TextField through the phone mobile scroll softbuttons then I can navigate to the TextField without clicking it and I can type any letters ! So how to call the VirtualKeyboard when typing a letter on the phone mobile ?

NB : I wrote System.out.println("zzzz"); in the dataChanged(int type, int index) method and the output writes two lines "zzzz" when I type one character ! So why the dataChanged method is called two times when I type only one letter ?

bharath
  • 14,283
  • 16
  • 57
  • 95
  • I´m not sure to understand what are you calling "the phone mobile scroll SoftButtons". Take a look here: http://lwuit.blogspot.com/2010/06/pimp-virtualkeyboard-by-chen-fishbein.html – Mun0n Oct 21 '11 at 07:29

1 Answers1

1

No need to use VKBImplementationFactory.init(); in startApp(). Because LWUIT automatically detect whether that mobile is touch screen or not. And numeric constraint not working on VKB when you use LWUIT 1.5 or before versions. It is bug on that versions. But it will be fixed on current repository version of LWUIT (Revision: 1605). So you can checkout from repository and use the latest LWUIT jar.

Update:

See the sample code for showing VKB while focusing on TextField,

TextField textField = new TextField();
final VirtualKeyboard keyboard = new VirtualKeyboard();
textField.addFocusListener(new FocusListener() {

     public void focusGained(Component cmp) 
          keyboard.show();
     }
     public void focusLost(Component cmp) {
          keyboard.dispose();
     }
});
keyboard.setTextField(textField);
Community
  • 1
  • 1
bharath
  • 14,283
  • 16
  • 57
  • 95
  • NO ! `VKBImplementationFactory.init();` IS ALWAYS NECESSARY IN `startApp()` !!! I TRIED TO REMOVE IT AND THE VKB IS NOT SHOWN WHEN CLICKING THE FIELD !!! KARANA TAY !!! –  Oct 21 '11 at 07:51
  • which version of LWUIT you are using? – bharath Oct 21 '11 at 09:29
  • the version of LWUIT I use is 1.4 –  Oct 21 '11 at 09:32
  • that version you need to use `VKBImplementationFactory.init()`. Why you dont try with latest version? – bharath Oct 21 '11 at 09:46
  • Does the latest version can answer my need ? That is : how to show the VKB when I edit a TextField without clicking it ? –  Oct 21 '11 at 10:31
  • LWUIT latest resolve some bugs like numeric constraint in `VKB`. If you need always open `VKB`, Just see my update in my answer and it just sample. you need modify for your needs. – bharath Oct 21 '11 at 10:55