【问题标题】:how to get long press event of textfield in codename one如何在代号一中获取文本字段的长按事件
【发布时间】:2014-07-02 04:18:36
【问题描述】:

我正在代号一开发。

我有一种形式的 TextField。

我想在TextField的长按事件上打开一个对话框

那么我怎样才能获得代号一中TextField的长按事件

我已经尝试过执行 ActionEvent 并检查过

if(event.isLongEvent()){

}

但它不起作用..

有什么想法吗?

提前致谢。 阿卡什

【问题讨论】:

    标签: textfield codenameone long-press


    【解决方案1】:

    这个有效:

    Button button = new Button("Test") {
        @Override
        public void longPointerPress(int x, int y) {
            System.out.println("LONG PRESS");
    
        }
    };
    

    【讨论】:

      【解决方案2】:

      由于文本字段使用本机编辑,长按事件将被本机编辑功能抓取,因此对于文本字段,它无法正常工作。

      您可以派生大多数组件并覆盖 longPress 或向表单添加长按侦听器,这将产生类似的效果,但可能会导致原生输入出现问题。

      【讨论】:

      • 我尝试通过添加findPOnumber().addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if(evt.isLongEvent()){ Dialog.show("Long","Long Pressed..!", "Ok", null); } } }); 它不起作用我也尝试通过将事件添加到表单f.addPointerPressedListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Log.p("form actionPerformed... "); if(evt.isLongEvent()){ Dialog.show("Long","Long Press","Ok",null); } } }); 仍然不起作用你能给我一些例子吗?仅供参考:我是 CodenameOne 的新手,谢谢
      猜你喜欢
      • 1970-01-01
      • 2016-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多