S40 Touch API-Text Editor API

Source: Internet
Author: User

TextEditor is an editable text component that is directly drawn on a Canvas or CustomItem.

Engineers with game programming experience must have encountered the need to enter Chinese characters in the game. In this case, the interface is switched to the control window instead of entering English letters or pinyin letters. After Entering Chinese characters, return to the game page. The implementation of TextEditor completely solves this problem.

The main methods of TextEditor include:

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()

When creating a TextEditor instance, instead of using the common new) method, it is implemented through two overloaded factory methods of TextEditor. The parameters of these two methods are slightly different and can be selected as needed.

// 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)

The following code demonstrates how to use 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.