Input Method inputconnection

Source: Internet
Author: User
/**
* The inputconnection interface is the communication channel from
* {@ Link inputmethod} back to the application that is processing ing its
* Input. It is used to perform such things as reading text around
* Cursor, committing text to the text box, and sending raw key events
* To the application.
* Inputconnection is a communication channel between the input method and the application. The application receives inputconnection input. inputconnection reads text from cursor cyclically and submits the text to the input box. And send key commands to the application.
* <P> Applications shocould never directly implement this interface,
* Instead subclass from {@ link baseinputconnection}. This will ensure
* That the application does not break when new methods are added
* The interface. </P>
* The application should not directly implement this interface, but implement its sub-class baseinputconnection. Subclass will ensure that the application will not stop running during running, if inputconnection adds a new method.
* <H3> implementing an IME or an Editor * <P> text input is the result of the synergy of two essential components:
* An Input Method engine (IME) and an editor. The IME can be
* Software keyboard, a handwriting interface, an emoji palette,
* Speech-to-text engine, and so on. There are typically several IMES
* Installed on any given Android device. In Android, Imes extend
* {@ Link Android. inputmethodservice. inputmethodservice }.
* For more information about how to create an IME, see
* <A href = "{@ docroot} Guide/topics/text/creating-input-method.html">
* Creating an input method </a> Guide.
* Text input is the result of two elements. Input Method Applications and controls.
The first element is the input method application. The input method can be soft keyboard, tablet, emoticon, and voice input engine.
Several input methods are installed on Android devices by default. In Android, the input method application inherits from inputmethodservice.
* The editor is the component that contains es text and displays it.
* Typically, this is an {@ link Android. widget. edittext} instance,
* Some applications may choose to implement their own editor
* Various reasons. This is a large and complicated task, and
* Application that does this needs to make sure the behavior is
* Consistent with standard edittext behavior in Android. An Editor
* Needs to interact with the IME, using ing commands through
* This inputconnection interface, and sending commands through
* {@ Link Android. View. inputmethod. inputmethodmanager}. An Editor
* Shocould start by implementing
* {@ Link Android. View. view # oncreateinputconnection (editorinfo )}
* To return its own input connection. </P>
* Second element: Editor. The editor is a control that receives and displays the text submitted by the input method. By default, this control is called edittext, but many applications also implement their own controls based on specific requirements. Implementing custom controls is a big and complex task.
At the same time, the application must ensure that the controls they implement comply with the android standard edittext behavior specification.
The control must communicate with the input method. The control can receive the text submitted by the input method through inputconnection and send the command to the input method through inputmethodmanager.
The control obtains its inputconnection object through oncreateinputconnection.
* <P> if you are implementing your own IME, you will need to call
* Methods in this interface to interact with the application. Be sure
* To test your IME with a wide range of applications, including
* Browsers and Rich Text editors, as some may have peculiarities you
* Need to deal with. Remember your IME may not be the only source
* Changes on the text, and try to be as conservative as possible in
* The data you send and as liberal as possible in the data you
* Receive. </P>
* If you have implemented your input method program, you need to call the method to maintain communication with the application. Make sure that your input method program has passed the testing of a large number of applications, such as browsers and submitting a large amount of data to the control, because some applications contain specific input specifications, you need to process specific input rules.
Remember, your input method program is not the only source that changes the text content in the control. Therefore, be cautious with the text you submit and the data you receive.
* <P> if you are implementing your own editor, you will probably need
* To provide your own subclass of {@ link baseinputconnection}
* Answer to the commands from imes. please be sure to test your
* Editor with as your imes as you can as their behavior can vary
* Lot. Also Be sure to test with various versions, including CJK
* Ages and right-to-left ages like Arabic, as these may
* Have different input requirements. When in doubt about
* Behavior you shoshould adopt for a special call, please mimic
* Default textview implementation in the latest Android version, and
* If you decide to drift from it, please consider carefully that
* Inconsistencies in text edition behavior is almost universally felt
* As a bad thing by users. </P>
* If you implement your own editor, you need to provide your own baseinputconnection subclass instance, which is used to maintain a response with the input method application.
Make sure that your controls pass most of the input method tests because their behavior is changeable. At the same time, make sure that tests are performed in multiple languages, including CJK or languages from right to left, such as Arabic. These languages have many different input requirements.
When you have doubts about the implemented controls, you can call us or imitate the textview implementation of the latest Android version. If you are sure to use it in your system, please consider that the text input of the control may make the user experience very bad.
* <H3> cursors, selections and compositions * <P> in Android, the cursor and the selection are one and the same
* Thing. A "cursor" is just the special case of a zero-sized
* Selection. As such, this documentation uses them
* Interchangeably. Any method acting "before the cursor" wocould Act
* Before the start of the selection if there is one, and any method
* Acting "after the cursor" wocould act after the end of
* Selection. </P>
* In Android, the cursor and the selected content are one thing. The cursor is the selected content of 0 content. Therefore, they can be exchanged in Android.
Any method of submission before the cursor is performed before the selected content is submitted. Similarly, after the cursor is submitted, the same behavior is performed after the selected content.
* <P> An editor needs to be able to keep track of a currently
* "Composing" region, like the Standard Edition widgets do.
* Composition is marked in a specific style: see
* {@ Link Android. Text. spanned # span_composing}. imes use this to help
* The user keep track of what part of the text they are currently
* Focusing on, and interact with the editor using
* {@ Link inputconnection # setcomposingtext (charsequence, INT )},
* {@ Link inputconnection # setcomposingregion (INT, INT)} And
* {@ Link inputconnection # finishcomposingtext ()}.
* The composing region and the selection are completely independent
* Of each other, and the IME may use them however they see fit. </P>
*/
Editor controls must be able to maintain the ability to write content areas, just like standard editing widgets.
The writing area will be applied with specific styles, such as Android. text. spanned # span_composing: the input method is used to help you maintain the ability to track the text content that is currently getting the focus, through setcomposingtext or finishcomposingtext.

Input Method inputconnection

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.