S40 Touch API - Text Editor API

网友投稿 245 2023-05-11

TextEditor是一个可编辑的文本组件,它直接绘制在Canvas或CustomItem上。

有过游戏编程经验的工程师一定碰到过需要在游戏中输入中文的情况。遇到这种情况,不是索性用输入英文或拼音字母代替,就是将界面切换到使用控件的窗口,待输入完中文后,再返回游戏页面。TextEditor的实现,彻底解决了这个问题。

TextEditor的主要方法包括:

复制boolean register( x, y, maxFps, maxPps, FrameAnimatorListenerlistener) void unregister() boolean isRegistered() static int getNumRegisteredFrameAnimators(); void drag(x, y) void kineticScroll( int startSpeed, int direction, int friction, float angle ) void stop()1.2.3.4.5.6.7.

在创建TextEditor的实例的时候,不是使用常用的new()方法,而是通过TextEditor 的两个重载的工厂方法实现的。这两个方法的参数略有不同,可根据实际情况选择使用。

复制// Creates a new empty TextEditor with the given maximum size in characters, constraints and editor size as number of visible rows. static TextEditor createTextEditor(int maxSize, int constraints, int width, int rows) // Creates a new TextEditor object with the given initial contents, maximum size in characters, constraints and editor size in pixels. static TextEditor createTextEditor(java.lang.String text, int maxSize, int constraints, int width, int height)1.2.3.4.5.

下面的代码演示了如何使用TextEditor:

复制TextEditor editor=TextEditor.createTextEditor("abc", 20, TextField.ANY, getWidth()-20, 100); editor.setMultiline(true); editor.setVisible(true); editor.setFocus(true); editor.setPosition(10, 10); editor.setParent(this); // this point to a Canvas1.2.3.4.5.6.

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:数据API经济与大规模数据流通:从水的寓言说起
下一篇:S40 Touch API - Frame Animator API
相关文章

 发表评论

暂时没有评论,来抢沙发吧~