简体   繁体   English

J2me中的TextEdit / TextBox onKey事件

[英]TextEdit/TextBox onKey events in J2me

I'm developing (or trying to) a J2ME application. 我正在开发(或尝试)J2ME应用程序。 I need to be able to handle onKeyEvents (keyDown/keyPressed/keyUp...) in TextEdit/TextBoxes, but I've learned that such thing is not possible in J2me, at least not in a simple way as in Java/Android development (myEdit.setOnKeyListener() for example). 我需要能够处理TextEdit / TextBoxes中的onKeyEvents(keyDown / keyPressed / keyUp ...),但我已经了解到这样的事情在J2me中是不可能的,至少不像Java / Android开发那样简单。 (例如,myEdit.setOnKeyListener())。 I've read something about using Canvas, but I'm not sure how can I use that to make it work for me. 我已经阅读了一些关于使用Canvas的内容,但我不确定如何使用它来使它适合我。

Answer to this question ( Image in button - j2me ) involves using the CustomItem class and make an item look/act like a Button. 对这个问题的回答( 按钮中的图像 - j2me )涉及使用CustomItem类并使项目外观/行为像Button。 Is there anyway to use the same approach? 无论如何使用相同的方法?

The TextBox and TextField objects are high-level GUI stuff, available when doing javax.microedition.lcdui.Form stuff. TextBoxTextField对象是高级GUI内容,在执行javax.microedition.lcdui.Form时可用。

In order to use keyPressed() and keyReleased() you must use javax.microedition.lcdui.Canvas (low-level GUI stuff). 要使用keyPressed()keyReleased() ,必须使用javax.microedition.lcdui.Canvas (低级GUI内容)。

But what you're probably really after, is LWUIT ( https://lwuit.java.net ). 但你真正想要的是LWUIT( https://lwuit.java.net )。 It is a framework built on javax.microedition.lcdui.Canvas which gives you a Form-like API with all the things javax.microedition.lcdui.Form is missing. 它是一个基于javax.microedition.lcdui.Canvas构建的框架,它为您提供了一个类似于Form的API,其中缺少javax.microedition.lcdui.Form

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM