当前位置: 首页>>代码示例>>Java>>正文


Java KeyEvent.getCharacters方法代码示例

本文整理汇总了Java中android.view.KeyEvent.getCharacters方法的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.getCharacters方法的具体用法?Java KeyEvent.getCharacters怎么用?Java KeyEvent.getCharacters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.KeyEvent的用法示例。


在下文中一共展示了KeyEvent.getCharacters方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onKeyMultiple

import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKeyMultiple(int keyCode, int repeatCount, final KeyEvent event)
{
	if( event.getCharacters() != null )
	{
		// International text input
		for(int i = 0; i < event.getCharacters().length(); i++ )
		{
			nativeKey( event.getKeyCode(), 1, event.getCharacters().codePointAt(i), 0 );
			nativeKey( event.getKeyCode(), 0, event.getCharacters().codePointAt(i), 0 );
		}
	}
	return true;
}
 
开发者ID:NeoTerm,项目名称:NeoTerm,代码行数:15,代码来源:Video.java

示例2: sendKeyEvent

import android.view.KeyEvent; //导入方法依赖的package包/类
public void sendKeyEvent(final KeyEvent keyEvent) {
    if (DEBUG_BATCH_NESTING) checkBatchEdit();
    if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
        if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug();
        // This method is only called for enter or backspace when speaking to old applications
        // (target SDK <= 15 (Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)), or for digits.
        // When talking to new applications we never use this method because it's inherently
        // racy and has unpredictable results, but for backward compatibility we continue
        // sending the key events for only Enter and Backspace because some applications
        // mistakenly catch them to do some stuff.
        switch (keyEvent.getKeyCode()) {
        case KeyEvent.KEYCODE_ENTER:
            mCommittedTextBeforeComposingText.append("\n");
            mExpectedSelStart += 1;
            mExpectedSelEnd = mExpectedSelStart;
            break;
        case KeyEvent.KEYCODE_DEL:
            if (0 == mComposingText.length()) {
                if (mCommittedTextBeforeComposingText.length() > 0) {
                    mCommittedTextBeforeComposingText.delete(
                            mCommittedTextBeforeComposingText.length() - 1,
                            mCommittedTextBeforeComposingText.length());
                }
            } else {
                mComposingText.delete(mComposingText.length() - 1, mComposingText.length());
            }
            if (mExpectedSelStart > 0 && mExpectedSelStart == mExpectedSelEnd) {
                // TODO: Handle surrogate pairs.
                mExpectedSelStart -= 1;
            }
            mExpectedSelEnd = mExpectedSelStart;
            break;
        case KeyEvent.KEYCODE_UNKNOWN:
            if (null != keyEvent.getCharacters()) {
                mCommittedTextBeforeComposingText.append(keyEvent.getCharacters());
                mExpectedSelStart += keyEvent.getCharacters().length();
                mExpectedSelEnd = mExpectedSelStart;
            }
            break;
        default:
            final String text = StringUtils.newSingleCodePointString(keyEvent.getUnicodeChar());
            mCommittedTextBeforeComposingText.append(text);
            mExpectedSelStart += text.length();
            mExpectedSelEnd = mExpectedSelStart;
            break;
        }
    }
    if (isConnected()) {
        mIC.sendKeyEvent(keyEvent);
    }
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:52,代码来源:RichInputConnection.java


注:本文中的android.view.KeyEvent.getCharacters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。