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


Java KeyEvent.hasModifiers方法代码示例

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


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

示例1: onKeyShortcut

import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKeyShortcut(int keyCode, KeyEvent event) {
    if (event.hasModifiers(KeyEvent.META_CTRL_ON)) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_A:
                if (mState == State.WORKSPACE) {
                    showAppsView(true, false);
                    return true;
                }
                break;
            case KeyEvent.KEYCODE_S: {
                View focusedView = getCurrentFocus();
                if (focusedView instanceof BubbleTextView
                        && focusedView.getTag() instanceof ItemInfo
                        && mAccessibilityDelegate.performAction(focusedView,
                                (ItemInfo) focusedView.getTag(),
                                LauncherAccessibilityDelegate.DEEP_SHORTCUTS)) {
                    PopupContainerWithArrow.getOpen(this).requestFocus();
                    return true;
                }
                break;
            }
            case KeyEvent.KEYCODE_O:
                if (new CustomActionsPopup(this, getCurrentFocus()).show()) {
                    return true;
                }
                break;
        }
    }
    return super.onKeyShortcut(keyCode, event);
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:32,代码来源:Launcher.java

示例2: onKeyDown

import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    // We need to handle focus change within the SimpleMonthView because we are simulating
    // multiple Views. The arrow keys will move between days until there is no space (no
    // day to the left, top, right, or bottom). Focus forward and back jumps out of the
    // SimpleMonthView, skipping over other SimpleMonthViews in the parent ViewPager
    // to the next focusable View in the hierarchy.
    boolean focusChanged = false;
    switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
            if (event.hasNoModifiers()) {
                focusChanged = moveOneDay(isLayoutRtl());
            }
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            if (event.hasNoModifiers()) {
                focusChanged = moveOneDay(!isLayoutRtl());
            }
            break;
        case KeyEvent.KEYCODE_DPAD_UP:
            if (event.hasNoModifiers()) {
                ensureFocusedDay();
                if (mHighlightedDay > 7) {
                    mHighlightedDay -= 7;
                    focusChanged = true;
                }
            }
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            if (event.hasNoModifiers()) {
                ensureFocusedDay();
                if (mHighlightedDay <= mDaysInMonth - 7) {
                    mHighlightedDay += 7;
                    focusChanged = true;
                }
            }
            break;
        case KeyEvent.KEYCODE_DPAD_CENTER:
        case KeyEvent.KEYCODE_ENTER:
            if (mHighlightedDay != -1) {
                onDayClicked(mHighlightedDay);
                return true;
            }
            break;
        case KeyEvent.KEYCODE_TAB: {
            int focusChangeDirection = 0;
            if (event.hasNoModifiers()) {
                focusChangeDirection = View.FOCUS_FORWARD;
            } else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {
                focusChangeDirection = View.FOCUS_BACKWARD;
            }
            if (focusChangeDirection != 0) {
                final ViewParent parent = getParent();
                // move out of the ViewPager next/previous
                View nextFocus = this;
                do {
                    nextFocus = nextFocus.focusSearch(focusChangeDirection);
                } while (nextFocus != null && nextFocus != this &&
                        nextFocus.getParent() == parent);
                if (nextFocus != null) {
                    nextFocus.requestFocus();
                    return true;
                }
            }
            break;
        }
    }
    if (focusChanged) {
        invalidate();
        return true;
    } else {
        return super.onKeyDown(keyCode, event);
    }
}
 
开发者ID:Gericop,项目名称:DateTimePicker,代码行数:75,代码来源:SimpleMonthView.java

示例3: isUninstallKeyChord

import android.view.KeyEvent; //导入方法依赖的package包/类
/**
 * Returns whether the key event represents a valid uninstall key chord.
 */
private static boolean isUninstallKeyChord(KeyEvent event) {
    int keyCode = event.getKeyCode();
    return (keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_FORWARD_DEL) &&
            event.hasModifiers(KeyEvent.META_CTRL_ON | KeyEvent.META_SHIFT_ON);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:9,代码来源:FocusHelper.java

示例4: isDeleteKeyChord

import android.view.KeyEvent; //导入方法依赖的package包/类
/**
 * Returns whether the key event represents a valid delete key chord.
 */
private static boolean isDeleteKeyChord(KeyEvent event) {
    int keyCode = event.getKeyCode();
    return (keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_FORWARD_DEL) &&
            event.hasModifiers(KeyEvent.META_CTRL_ON);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:9,代码来源:FocusHelper.java


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