LWUIT 1.4 - 为什么在文本字段编辑期间首次显示后不出现虚拟键盘?

发布于 2024-12-21 12:50:34 字数 2848 浏览 6 评论 0原文

我想在用户编辑文本字段时显示虚拟键盘。我采用这种方法:

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;
    }
    ...
}

问题是,当我第一次编辑 textfield 时,会显示 virtualkeyboard ;然后我单击 virtualkeyboardOk 按钮,然后再次编辑 textfield。但此时虚拟键盘没有显示!

那么如何让每次编辑 textfield 时都显示 virtualkeyboard 呢?

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

碍人泪离人颜 2024-12-28 12:50:34

这完全有可能是 1.4 的一个错误,但在 1.5 中已修复,因为我现在看不到它。 VKB 在 1.4 中是全新的。

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 .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文