Example usage for android.text.method MetaKeyKeyListener handleKeyDown

List of usage examples for android.text.method MetaKeyKeyListener handleKeyDown

Introduction

In this page you can find the example usage for android.text.method MetaKeyKeyListener handleKeyDown.

Prototype

public static long handleKeyDown(long state, int keyCode, KeyEvent event) 

Source Link

Document

Handles presses of the meta keys.

Usage

From source file:research.sg.edu.edapp.kb.KbSoftKeyboard.java

/**
 * This translates incoming hard key events in to edit operations on an
 * InputConnection.  It is only needed when using the
 * PROCESS_HARD_KEYS option./*  www.  j ava 2  s .  co m*/
 */

private boolean translateKeyDown(int keyCode, KeyEvent event) {
    mMetaState = MetaKeyKeyListener.handleKeyDown(mMetaState, keyCode, event);
    int c = event.getUnicodeChar(MetaKeyKeyListener.getMetaState(mMetaState));
    mMetaState = MetaKeyKeyListener.adjustMetaAfterKeypress(mMetaState);
    InputConnection ic = getCurrentInputConnection();
    if (c == 0 || ic == null) {
        return false;
    }

    boolean dead = false;

    if ((c & KeyCharacterMap.COMBINING_ACCENT) != 0) {
        dead = true;
        c = c & KeyCharacterMap.COMBINING_ACCENT_MASK;
    }

    if (mComposing.length() > 0) {
        char accent = mComposing.charAt(mComposing.length() - 1);
        int composed = KeyEvent.getDeadChar(accent, c);

        if (composed != 0) {
            c = composed;
            mComposing.setLength(mComposing.length() - 1);
        }
    }

    Log.d("Cum", "Cum");
    onKey(c, null);

    return true;
}

From source file:com.strathclyde.highlightingkeyboard.SoftKeyboardService.java

/**
 * This translates incoming hard key events in to edit operations on an
 * InputConnection.  It is only needed when using the
 * PROCESS_HARD_KEYS option./*  ww w .  j  ava2  s  . co  m*/
 */
private boolean translateKeyDown(int keyCode, KeyEvent event) {
    mMetaState = MetaKeyKeyListener.handleKeyDown(mMetaState, keyCode, event);
    int c = event.getUnicodeChar(MetaKeyKeyListener.getMetaState(mMetaState));
    mMetaState = MetaKeyKeyListener.adjustMetaAfterKeypress(mMetaState);
    //InputConnection ic = ic;
    if (c == 0 || ic == null) {
        return false;
    }

    if ((c & KeyCharacterMap.COMBINING_ACCENT) != 0) {
        c = c & KeyCharacterMap.COMBINING_ACCENT_MASK;
    }

    if (mComposing.length() > 0) {
        char accent = mComposing.charAt(mComposing.length() - 1);
        int composed = KeyEvent.getDeadChar(accent, c);

        if (composed != 0) {
            c = composed;
            mComposing.setLength(mComposing.length() - 1);
        }
    }

    onKey(c, null);

    return true;
}