当前位置:首页 >时尚 >S40 Touch API 彻底解决了这个问题

S40 Touch API 彻底解决了这个问题

2024-06-30 20:24:27 [百科] 来源:避面尹邢网

S40 Touch API - Text Editor API

作者:max.chen 移动开发 TextEditor是一个可编辑的文本组件,它直接绘制在Canvas或CustomItem上。

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

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

S40 Touch API 彻底解决了这个问题

TextEditor的主要方法包括:

S40 Touch API 彻底解决了这个问题

booleanregister( x, y, maxFps, maxPps, FrameAnimatorListenerlistener)	
voidunregister()
booleanisRegistered()
staticintgetNumRegisteredFrameAnimators();
voiddrag(x, y)
voidkineticScroll( intstartSpeed, intdirection, intfriction, floatangle )
voidstop()

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

S40 Touch API 彻底解决了这个问题

// Creates a new empty TextEditor with the given maximum size in characters, constraints and editor size as number of visible rows.
staticTextEditor createTextEditor(intmaxSize, intconstraints, intwidth, introws)

// Creates a new TextEditor object with the given initial contents, maximum size in characters, constraints and editor size in pixels.
staticTextEditor createTextEditor(java.lang.String text, intmaxSize, intconstraints, intwidth, intheight)

下面的代码演示了如何使用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 Canvas

 

责任编辑:Yeva 来源: NOKIA Developer S40Series 40

(责任编辑:百科)

    推荐文章
    热点阅读