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


Java KeyEvent.isAltPressed方法代码示例

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


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

示例1: executeKeyEvent

import android.view.KeyEvent; //导入方法依赖的package包/类
public boolean executeKeyEvent(KeyEvent event) {
    this.mTempRect.setEmpty();
    if (canScroll()) {
        boolean handled = false;
        if (event.getAction() == 0) {
            switch (event.getKeyCode()) {
                case 19:
                    if (!event.isAltPressed()) {
                        handled = arrowScroll(33);
                        break;
                    }
                    handled = fullScroll(33);
                    break;
                case 20:
                    if (!event.isAltPressed()) {
                        handled = arrowScroll(130);
                        break;
                    }
                    handled = fullScroll(130);
                    break;
                case 62:
                    pageScroll(event.isShiftPressed() ? 33 : 130);
                    break;
            }
        }
        return handled;
    } else if (!isFocused() || event.getKeyCode() == 4) {
        return false;
    } else {
        View currentFocused = findFocus();
        if (currentFocused == this) {
            currentFocused = null;
        }
        View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, 130);
        if (nextFocused == null || nextFocused == this || !nextFocused.requestFocus(130)) {
            return false;
        }
        return true;
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:41,代码来源:NestedScrollView.java

示例2: executeKeyEvent

import android.view.KeyEvent; //导入方法依赖的package包/类
/**
 * You can call this function yourself to have the scroll view perform
 * scrolling from a key event, just as if the event had been dispatched to
 * it by the view hierarchy.
 *
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event) {
    mTempRect.setEmpty();
    if (!canScroll()) {
        if (isFocused()) {
            View currentFocused = findFocus();
            if (currentFocused == this) currentFocused = null;
            View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, View.FOCUS_DOWN);
            return nextFocused != null && nextFocused != this && nextFocused.requestFocus(View.FOCUS_DOWN);
        }
        return false;
    }
    boolean handled = false;
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
            case KeyEvent.KEYCODE_DPAD_UP:
                if (!event.isAltPressed()) {
                    handled = arrowScroll(View.FOCUS_UP, false);
                } else {
                    handled = fullScroll(View.FOCUS_UP, false);
                }
                break;
            case KeyEvent.KEYCODE_DPAD_DOWN:
                if (!event.isAltPressed()) {
                    handled = arrowScroll(View.FOCUS_DOWN, false);
                } else {
                    handled = fullScroll(View.FOCUS_DOWN, false);
                }
                break;
            case KeyEvent.KEYCODE_DPAD_LEFT:
                if (!event.isAltPressed()) {
                    handled = arrowScroll(View.FOCUS_LEFT, true);
                } else {
                    handled = fullScroll(View.FOCUS_LEFT, true);
                }
                break;
            case KeyEvent.KEYCODE_DPAD_RIGHT:
                if (!event.isAltPressed()) {
                    handled = arrowScroll(View.FOCUS_RIGHT, true);
                } else {
                    handled = fullScroll(View.FOCUS_RIGHT, true);
                }
                break;
        }
    }
    return handled;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:55,代码来源:TwoDScrollView.java

示例3: getMetaState

import android.view.KeyEvent; //导入方法依赖的package包/类
private static int getMetaState(KeyEvent event) {
    return (event.isCtrlPressed() ? CTRL : 0)
            | (event.isAltPressed() ? ALT : 0)
            | (event.isShiftPressed() ? SHIFT : 0);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:6,代码来源:KeyboardShortcuts.java

示例4: onKey

import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
    if(event.getAction() == 0 && event.isCtrlPressed()
            && !event.isShiftPressed()
            && !event.isAltPressed()
            && !event.isFunctionPressed()
            && keyCode == KeyEvent.KEYCODE_X) {
        cut(); //Ctrl+X
        return true;
    } else if(event.getAction() == 0 && event.isCtrlPressed()
            && !event.isShiftPressed()
            && !event.isAltPressed()
            && !event.isFunctionPressed()
            && keyCode == KeyEvent.KEYCODE_C) {
        copy(); //Ctrl-C
        return true;
    } else if(event.getAction() == 0 && event.isCtrlPressed()
            && !event.isShiftPressed()
            && !event.isAltPressed()
            && !event.isFunctionPressed()
            && keyCode == KeyEvent.KEYCODE_V) {
        paste(); //Ctrl-V
        return true;
    } else if(event.getAction() == 0 && event.isCtrlPressed()
            && !event.isShiftPressed()
            && !event.isAltPressed()
            && !event.isFunctionPressed()
            && keyCode == KeyEvent.KEYCODE_Z) {
        undo(); //Ctrl-Z
        return true;
    } else if(event.getAction() == 0 && event.isCtrlPressed()
            && !event.isShiftPressed()
            && !event.isAltPressed()
            && !event.isFunctionPressed()
            && keyCode == KeyEvent.KEYCODE_Y) {
        redo(); //Ctrl-Y
        return true;
    } else if(event.getAction() == 0 && event.isCtrlPressed()
            && !event.isShiftPressed()
            && !event.isAltPressed()
            && !event.isFunctionPressed()
            && keyCode == KeyEvent.KEYCODE_A) {
        selectAll(); //Ctrl-A
        return true;
    } else if(event.getAction() == 0 && event.isCtrlPressed()
            && event.isShiftPressed()
            && !event.isAltPressed()
            && !event.isFunctionPressed()
            && keyCode == KeyEvent.KEYCODE_D) {
        deleteLine(); //Ctrl+Shift-D
        return true;
    } else if(event.getAction() == 0 && event.isCtrlPressed()
            && !event.isShiftPressed()
            && event.isAltPressed()
            && !event.isFunctionPressed()
            && keyCode == KeyEvent.KEYCODE_A) {
        selectLine(); //Ctrl+Alt-A
        return true;
    } else {
        return false;
    }
}
 
开发者ID:Light-Team,项目名称:ModPE-IDE-Source,代码行数:63,代码来源:LModEditor.java

示例5: executeKeyEvent

import android.view.KeyEvent; //导入方法依赖的package包/类
/**
 * You can call this function yourself to have the scroll view perform scrolling from a key event, just as if the
 * event had been dispatched to it by the view hierarchy.
 *
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event)
{
    mTempRect.setEmpty();
    boolean handled = false;
    if (event.getAction() == KeyEvent.ACTION_DOWN)
    {
        switch (event.getKeyCode())
        {
        case KeyEvent.KEYCODE_DPAD_UP:
            if (!event.isAltPressed())
            {
                handled = arrowScroll(View.FOCUS_UP, false);
            }
            else
            {
                handled = fullScroll(View.FOCUS_UP, false);
            }
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            if (!event.isAltPressed())
            {
                handled = arrowScroll(View.FOCUS_DOWN, false);
            }
            else
            {
                handled = fullScroll(View.FOCUS_DOWN, false);
            }
            break;
        case KeyEvent.KEYCODE_DPAD_LEFT:
            if (!event.isAltPressed())
            {
                handled = arrowScroll(View.FOCUS_LEFT, true);
            }
            else
            {
                handled = fullScroll(View.FOCUS_LEFT, true);
            }
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            if (!event.isAltPressed())
            {
                handled = arrowScroll(View.FOCUS_RIGHT, true);
            }
            else
            {
                handled = fullScroll(View.FOCUS_RIGHT, true);
            }
            break;
        }
    }
    return handled;
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:60,代码来源:TwoDScrollView.java

示例6: onKeyDown

import android.view.KeyEvent; //导入方法依赖的package包/类
@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,代码行数:77,代码来源:TerminalView.java


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