當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyEvent.ACTION_MULTIPLE屬性代碼示例

本文整理匯總了Java中android.view.KeyEvent.ACTION_MULTIPLE屬性的典型用法代碼示例。如果您正苦於以下問題:Java KeyEvent.ACTION_MULTIPLE屬性的具體用法?Java KeyEvent.ACTION_MULTIPLE怎麽用?Java KeyEvent.ACTION_MULTIPLE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.view.KeyEvent的用法示例。


在下文中一共展示了KeyEvent.ACTION_MULTIPLE屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: dispatchKeyEvent

/**
 * @brief Captures the keys of the keyboard
 * @param event The event
 * @details Capture the keys of the keyboard. If the character has to be pressed with a combination of the shift key 
 * and other key then adds 100 to the modKeyCount attribute to applies the offset
 */
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
	if(event.getAction() == KeyEvent.ACTION_DOWN || event.getAction() == KeyEvent.ACTION_UP|| event.getAction() == KeyEvent.ACTION_MULTIPLE){
		int keyunicode = event.getUnicodeChar(event.getMetaState() );
	    char character = (char) keyunicode;
	    int key = event.getKeyCode();
	    if(key == 59){
	    	if(modKeyCount == 0){
	    		modKeyCount = 100;
	    	}
	    	else{
	    		modKeyCount = 0;
	    	}
	    }
	    else if(key >= 7){
	    	boolean down = event.getAction() == KeyEvent.ACTION_DOWN;
	    	vnc.sendKey(modKeyCount+key,down);
	    	
	    }
	   
	    
	    Log.e(DEBUG_TAG,String.valueOf( event.getKeyCode()));
	}
    return super.dispatchKeyEvent(event);
}
 
開發者ID:CodyyAndroid,項目名稱:LibVNCAndroid,代碼行數:31,代碼來源:CanvasActivity.java

示例2: keyEventToJs

private ReturnObject keyEventToJs(KeyEvent event) {
    ReturnObject o = new ReturnObject();
    o.put("key", event.getKeyCode());
    o.put("id", event.getDeviceId());

    String action = "unknown";
    switch (event.getAction()) {
        case KeyEvent.ACTION_DOWN:
            action = "down";
            break;

        case KeyEvent.ACTION_UP:
            action = "up";
            break;

        case KeyEvent.ACTION_MULTIPLE:
            action = "multiple";
            break;
    }

    o.put("action", action);

    o.put("alt", event.isAltPressed());
    o.put("ctrl", event.isCtrlPressed());
    o.put("fn", event.isFunctionPressed());
    o.put("meta", event.isMetaPressed());
    o.put("chars", event.getCharacters());
    o.put("number", event.getNumber());

    return o;
}
 
開發者ID:victordiaz,項目名稱:phonk,代碼行數:31,代碼來源:PDevice.java

示例3: onKey

@Override
public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
    int action = keyEvent.getAction();

    // Work-around for spurious key event from IME, bug #1639445
    if(action == KeyEvent.ACTION_MULTIPLE && keyCode == KeyEvent.KEYCODE_UNKNOWN) {
        return true; // eat it
    }

    if(keyEvent.getUnicodeChar() == '=') {
        if(action == KeyEvent.ACTION_UP) {
            mHandler.onEnter();
        }
        return true;
    }

    if(keyCode != KeyEvent.KEYCODE_DPAD_CENTER && keyCode != KeyEvent.KEYCODE_DPAD_UP && keyCode != KeyEvent.KEYCODE_DPAD_DOWN
            && keyCode != KeyEvent.KEYCODE_ENTER) {
        if(keyEvent.isPrintingKey() && action == KeyEvent.ACTION_UP) {
            // Tell the handler that text was updated.
            mHandler.onTextChanged();
        }
        return false;
    }

    /*
     * We should act on KeyEvent.ACTION_DOWN, but strangely sometimes the
     * DOWN event isn't received, only the UP. So the workaround is to act
     * on UP... http://b/issue?id=1022478
     */

    if(action == KeyEvent.ACTION_UP) {
        switch(keyCode) {
        case KeyEvent.KEYCODE_ENTER:
        case KeyEvent.KEYCODE_DPAD_CENTER:
            mHandler.onEnter();
            break;

        case KeyEvent.KEYCODE_DPAD_UP:
            mHandler.onUp();
            break;

        case KeyEvent.KEYCODE_DPAD_DOWN:
            mHandler.onDown();
            break;
        }
    }
    return true;
}
 
開發者ID:gigabytedevelopers,項目名稱:CalcMate,代碼行數:49,代碼來源:EventListener.java

示例4: dispatchKeyEvent

@Override public boolean dispatchKeyEvent(KeyEvent event)
{
	if (event.getAction() == KeyEvent.ACTION_MULTIPLE)
		return mUnityPlayer.injectEvent(event);
	return super.dispatchKeyEvent(event);
}
 
開發者ID:Hand-Talk,項目名稱:android-library,代碼行數:6,代碼來源:UnityPlayerActivity.java

示例5: onKeyDown

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (LOG_KEY_EVENTS)
        Log.i(EmulatorDebug.LOG_TAG, "onKeyDown(keyCode=" + keyCode + ", isSystem()=" + event.isSystem() + ", event=" + event + ")");
    if (mEmulator == null) return true;

    if (mClient.onKeyDown(keyCode, event, mTermSession)) {
        invalidate();
        return true;
    } else if (event.isSystem() && (!mClient.shouldBackButtonBeMappedToEscape() || keyCode != KeyEvent.KEYCODE_BACK)) {
        return super.onKeyDown(keyCode, event);
    } else if (event.getAction() == KeyEvent.ACTION_MULTIPLE && keyCode == KeyEvent.KEYCODE_UNKNOWN) {
        mTermSession.write(event.getCharacters());
        return true;
    }

    final int metaState = event.getMetaState();
    final boolean controlDownFromEvent = event.isCtrlPressed();
    final boolean leftAltDownFromEvent = (metaState & KeyEvent.META_ALT_LEFT_ON) != 0;
    final boolean rightAltDownFromEvent = (metaState & KeyEvent.META_ALT_RIGHT_ON) != 0;

    int keyMod = 0;
    if (controlDownFromEvent) keyMod |= KeyHandler.KEYMOD_CTRL;
    if (event.isAltPressed()) keyMod |= KeyHandler.KEYMOD_ALT;
    if (event.isShiftPressed()) keyMod |= KeyHandler.KEYMOD_SHIFT;
    if (handleKeyCode(keyCode, keyMod)) {
        if (LOG_KEY_EVENTS) Log.i(EmulatorDebug.LOG_TAG, "handleKeyCode() took key event");
        return true;
    }

    // Clear Ctrl since we handle that ourselves:
    int bitsToClear = KeyEvent.META_CTRL_MASK;
    if (rightAltDownFromEvent) {
        // Let right Alt/Alt Gr be used to compose characters.
    } else {
        // Use left alt to send to terminal (e.g. Left Alt+B to jump back a word), so remove:
        bitsToClear |= KeyEvent.META_ALT_ON | KeyEvent.META_ALT_LEFT_ON;
    }
    int effectiveMetaState = event.getMetaState() & ~bitsToClear;

    int result = event.getUnicodeChar(effectiveMetaState);
    if (LOG_KEY_EVENTS)
        Log.i(EmulatorDebug.LOG_TAG, "KeyEvent#getUnicodeChar(" + effectiveMetaState + ") returned: " + result);
    if (result == 0) {
        return true;
    }

    int oldCombiningAccent = mCombiningAccent;
    if ((result & KeyCharacterMap.COMBINING_ACCENT) != 0) {
        // If entered combining accent previously, write it out:
        if (mCombiningAccent != 0)
            inputCodePoint(mCombiningAccent, controlDownFromEvent, leftAltDownFromEvent);
        mCombiningAccent = result & KeyCharacterMap.COMBINING_ACCENT_MASK;
    } else {
        if (mCombiningAccent != 0) {
            int combinedChar = KeyCharacterMap.getDeadChar(mCombiningAccent, result);
            if (combinedChar > 0) result = combinedChar;
            mCombiningAccent = 0;
        }
        inputCodePoint(result, controlDownFromEvent, leftAltDownFromEvent);
    }

    if (mCombiningAccent != oldCombiningAccent) invalidate();

    if (onAutoCompleteListener != null) {
        if (event.isPrintingKey()) {
            char printingChar = (char) event.getUnicodeChar(metaState);
            if (printingChar != '\b') {
                // ASCII chars
                onAutoCompleteListener.onCompletionRequired(new String(new char[]{printingChar}));
            }
        }
    }

    return true;
}
 
開發者ID:NeoTerm,項目名稱:NeoTerm,代碼行數:76,代碼來源:TerminalView.java


注:本文中的android.view.KeyEvent.ACTION_MULTIPLE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。