Frage

I want to show the virtual keyboard when the user is editing the textfield. I take this approach :

public class ChpModif extends TextField {

    public ChpModif(int maxChars, FocusListener focusListener, DataChangedListener dataChangeListener, VirtualKeyboard vkb)
    {
        super();
        setReplaceMenu(false);
        if (maxChars != -1)
            setMaxSize(maxChars);
        addFocusListener(focusListener);
        addDataChangeListener(dataChangeListener);
        if (vkb != null)
            VirtualKeyboard.bindVirtualKeyboard(this, vkb);
    }
    protected Command installCommands(Command clear, Command t9)
    {
        return null;
    }
}

public class ModifierFicheClient extends Ecran implements ActionListener, DataChangedListener, FocusListener
{
    private VirtualKeyboard vkNombre = new VirtualKeyboard();
    private String textFieldStatus, listBoxStatus;
    private ListBox genretxt;
    private boolean modifFromUpdate;
    private ChpModif nomtxt,prenomtxt,cintxt,adressetxt/*,genretxt*/,lieutxt,professiontxt,courieltxt,teltxt,datenaisstxt;
    private Component cursorItem;
    ...
    public ModifierFicheClient(SmartPhoneBanking controller,String prosp_id,int recordStoreID,Form prevForm)
    {
        super("");
        vkNombre.setInputModeOrder(new String[]{VirtualKeyboard.NUMBERS_SYMBOLS_MODE});
        ...
        modifFromUpdate = false;
        cintxt = new ChpModif(12, this, this, vkNombre);
        ...
    }
    public void dataChanged(int type, int index) {
        textFieldStatus = "CHANGED";
        if (!modifFromUpdate)
        {
            try
            {
                if (type == DataChangedListener.ADDED || type == DataChangedListener.CHANGED || type == DataChangedListener.REMOVED)
                {
                    if (Display.getInstance().isVirtualKeyboardShowingSupported())
                    {
                        if (!Display.getInstance().isVirtualKeyboardShowing())
                            cursorItem.pointerReleased(cursorItem.getAbsoluteX(), cursorItem.getAbsoluteY());
                    }
                }
            }
            catch (ClassCastException cce)
            {}
        }
    }
    public void focusGained(Component chp) {
        cursorItem = chp;
    }
    public void focusLost(Component arg0) {
    }
    protected void onShowCompleted()
    {
        ...
        update();
    }
    public void update()
    {
        modifFromUpdate = true;
        cintxt.setText(fichesignalitique.elementAt(0).toString());
        ...
        modifFromUpdate = false;
    }
    ...
}

The problem is that at the first time when I edit the textfield then the virtualkeyboard is shown ; then I click the Ok button of the virtualkeyboard , and then I edit again the textfield. But in this time the virtualkeyboard is not shown !

So how to make the virtualkeyboard shown everytime I edit the textfield ?

War es hilfreich?

Lösung

Its entirely possible that this is a 1.4 bug that was fixed in 1.5 since I can't see it right now. The VKB was brand new in 1.4 .

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top