本文整理汇总了Java中android.view.KeyEvent.KEYCODE_ESCAPE属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.KEYCODE_ESCAPE属性的具体用法?Java KeyEvent.KEYCODE_ESCAPE怎么用?Java KeyEvent.KEYCODE_ESCAPE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.view.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.KEYCODE_ESCAPE属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onKeyDown
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
//click mapping
if (keyCode==KeyEvent.KEYCODE_DPAD_CENTER && ocl != null) {
this.ocl.onClick(this);
return true;
}
else if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_BUTTON_B) {
if(onResult!=null)
onResult.onResult(DESTROYED);
exitDialog();
return true;
}
//handle focus on dialog
else if (keyCode == KeyEvent.KEYCODE_DPAD_UP||keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
View v = findFocus().focusSearch(keyCode == KeyEvent.KEYCODE_DPAD_UP?FOCUS_UP:FOCUS_DOWN);
if(v instanceof TVMenuSeparator)
v=v.focusSearch(keyCode == KeyEvent.KEYCODE_DPAD_UP?FOCUS_UP:FOCUS_DOWN);
if(isViewInCard(v))
v.requestFocus();
return true;
}
return true;
}
示例2: dispatchKeyEvent
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (mChildrenFocused && event.getKeyCode() == KeyEvent.KEYCODE_ESCAPE
&& event.getAction() == KeyEvent.ACTION_UP) {
mChildrenFocused = false;
requestFocus();
return true;
}
return super.dispatchKeyEvent(event);
}
示例3: onKey
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_UP) {
switch (keyCode) {
case KeyEvent.KEYCODE_ENTER:
mButtonSearch.performClick();
return true;
case KeyEvent.KEYCODE_ESCAPE:
mButtonClear.performClick();
return true;
}
}
return false;
}
示例4: handleKeyboardEvent
@Override
public void handleKeyboardEvent(KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN && mTab.getActivity() != null) {
if (mTab.getActivity().onKeyDown(event.getKeyCode(), event)) return;
// Handle the Escape key here (instead of in KeyboardShortcuts.java), so it doesn't
// interfere with other parts of the activity (e.g. the URL bar).
if (event.getKeyCode() == KeyEvent.KEYCODE_ESCAPE && event.hasNoModifiers()) {
WebContents wc = mTab.getWebContents();
if (wc != null) wc.stop();
return;
}
}
handleMediaKey(event);
}
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:15,代码来源:TabWebContentsDelegateAndroid.java
示例5: processKeyUp
/**
* For keyboard mode, processes key events.
*
* @param keyCode the pressed key.
* @return true if the key was successfully processed, false otherwise.
*/
private boolean processKeyUp(int keyCode) {
if (keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_BACK) {
dismiss();
return true;
} else if (keyCode == KeyEvent.KEYCODE_TAB) {
if (mInKbMode) {
if (isTypedTimeFullyLegal()) {
finishKbMode(true);
}
return true;
}
} else if (keyCode == KeyEvent.KEYCODE_ENTER) {
if (mInKbMode) {
if (!isTypedTimeFullyLegal()) {
return true;
}
finishKbMode(false);
}
sendBroadcastResult();
handleCallbackResult(mTimePicker);
dismiss();
return true;
} else if (keyCode == KeyEvent.KEYCODE_DEL) {
if (mInKbMode) {
if (!mTypedTimes.isEmpty()) {
int deleted = deleteLastTypedKey();
String deletedKeyStr;
if (deleted == getAmOrPmKeyCode(AM)) {
deletedKeyStr = mAmText;
} else if (deleted == getAmOrPmKeyCode(PM)) {
deletedKeyStr = mPmText;
} else {
deletedKeyStr = String.format(Locale.ENGLISH, "%d", getValFromKeyCode(deleted));
}
Utils.tryAccessibilityAnnounce(mTimePicker,
String.format(mDeletedKeyFormat, deletedKeyStr));
updateDisplay(true);
}
}
} else if (keyCode == KeyEvent.KEYCODE_0 || keyCode == KeyEvent.KEYCODE_1
|| keyCode == KeyEvent.KEYCODE_2 || keyCode == KeyEvent.KEYCODE_3
|| keyCode == KeyEvent.KEYCODE_4 || keyCode == KeyEvent.KEYCODE_5
|| keyCode == KeyEvent.KEYCODE_6 || keyCode == KeyEvent.KEYCODE_7
|| keyCode == KeyEvent.KEYCODE_8 || keyCode == KeyEvent.KEYCODE_9
|| (!mIs24HourMode &&
(keyCode == getAmOrPmKeyCode(AM) || keyCode == getAmOrPmKeyCode(PM)))) {
if (!mInKbMode) {
if (mTimePicker == null) {
// Something's wrong, because time picker should definitely not be null.
Log.e(TAG, "Unable to initiate keyboard mode, TimePicker was null.");
return true;
}
mTypedTimes.clear();
tryStartingKbMode(keyCode);
return true;
}
// We're already in keyboard mode.
if (addKeyIfLegal(keyCode)) {
updateDisplay(false);
}
return true;
}
return false;
}
示例6: processKeyUp
/**
* For keyboard mode, processes key events.
*
* @param keyCode the pressed key.
* @return true if the key was successfully processed, false otherwise.
*/
private boolean processKeyUp(int keyCode) {
if (keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_BACK) {
dismiss();
return true;
} else if (keyCode == KeyEvent.KEYCODE_TAB) {
if (mInKbMode) {
if (isTypedTimeFullyLegal()) {
finishKbMode(true);
}
return true;
}
} else if (keyCode == KeyEvent.KEYCODE_ENTER) {
if (mInKbMode) {
if (!isTypedTimeFullyLegal()) {
return true;
}
finishKbMode(false);
}
if (mCallback != null) {
mCallback.onTimeSet(mTimePicker,
mTimePicker.getHours(), mTimePicker.getMinutes());
}
dismiss();
return true;
} else if (keyCode == KeyEvent.KEYCODE_DEL) {
if (mInKbMode) {
if (!mTypedTimes.isEmpty()) {
int deleted = deleteLastTypedKey();
String deletedKeyStr;
if (deleted == getAmOrPmKeyCode(AM)) {
deletedKeyStr = mAmText;
} else if (deleted == getAmOrPmKeyCode(PM)) {
deletedKeyStr = mPmText;
} else {
deletedKeyStr = String.format("%d", getValFromKeyCode(deleted));
}
Utils.tryAccessibilityAnnounce(mTimePicker,
String.format(mDeletedKeyFormat, deletedKeyStr));
updateDisplay(true);
}
}
} else if (keyCode == KeyEvent.KEYCODE_0 || keyCode == KeyEvent.KEYCODE_1
|| keyCode == KeyEvent.KEYCODE_2 || keyCode == KeyEvent.KEYCODE_3
|| keyCode == KeyEvent.KEYCODE_4 || keyCode == KeyEvent.KEYCODE_5
|| keyCode == KeyEvent.KEYCODE_6 || keyCode == KeyEvent.KEYCODE_7
|| keyCode == KeyEvent.KEYCODE_8 || keyCode == KeyEvent.KEYCODE_9
|| (!mIs24HourMode &&
(keyCode == getAmOrPmKeyCode(AM) || keyCode == getAmOrPmKeyCode(PM)))) {
if (!mInKbMode) {
if (mTimePicker == null) {
// Something's wrong, because time picker should definitely not be null.
Log.e(TAG, "Unable to initiate keyboard mode, TimePicker was null.");
return true;
}
mTypedTimes.clear();
tryStartingKbMode(keyCode);
return true;
}
// We're already in keyboard mode.
if (addKeyIfLegal(keyCode)) {
updateDisplay(false);
}
return true;
}
return false;
}
示例7: processKeyUp
/**
* For keyboard mode, processes key events.
* @param keyCode the pressed key.
* @return true if the key was successfully processed, false otherwise.
*/
private boolean processKeyUp(int keyCode) {
if (keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_BACK) {
if(isCancelable()) dismiss();
return true;
} else if (keyCode == KeyEvent.KEYCODE_TAB) {
if(mInKbMode) {
if (isTypedTimeFullyLegal()) {
finishKbMode(true);
}
return true;
}
} else if (keyCode == KeyEvent.KEYCODE_ENTER) {
if (mInKbMode) {
if (!isTypedTimeFullyLegal()) {
return true;
}
finishKbMode(false);
}
if (mCallback != null) {
mCallback.onTimeSet(this,
mTimePicker.getHours(), mTimePicker.getMinutes(), mTimePicker.getSeconds());
}
dismiss();
return true;
} else if (keyCode == KeyEvent.KEYCODE_DEL) {
if (mInKbMode) {
if (!mTypedTimes.isEmpty()) {
int deleted = deleteLastTypedKey();
String deletedKeyStr;
if (deleted == getAmOrPmKeyCode(AM)) {
deletedKeyStr = mAmText;
} else if (deleted == getAmOrPmKeyCode(PM)) {
deletedKeyStr = mPmText;
} else {
deletedKeyStr = String.format("%d", getValFromKeyCode(deleted));
}
Utils.tryAccessibilityAnnounce(mTimePicker,
String.format(mDeletedKeyFormat, deletedKeyStr));
updateDisplay(true);
}
}
} else if (keyCode == KeyEvent.KEYCODE_0 || keyCode == KeyEvent.KEYCODE_1
|| keyCode == KeyEvent.KEYCODE_2 || keyCode == KeyEvent.KEYCODE_3
|| keyCode == KeyEvent.KEYCODE_4 || keyCode == KeyEvent.KEYCODE_5
|| keyCode == KeyEvent.KEYCODE_6 || keyCode == KeyEvent.KEYCODE_7
|| keyCode == KeyEvent.KEYCODE_8 || keyCode == KeyEvent.KEYCODE_9
|| (!mIs24HourMode &&
(keyCode == getAmOrPmKeyCode(AM) || keyCode == getAmOrPmKeyCode(PM)))) {
if (!mInKbMode) {
if (mTimePicker == null) {
// Something's wrong, because time picker should definitely not be null.
Log.e(TAG, "Unable to initiate keyboard mode, TimePicker was null.");
return true;
}
mTypedTimes.clear();
tryStartingKbMode(keyCode);
return true;
}
// We're already in keyboard mode.
if (addKeyIfLegal(keyCode)) {
updateDisplay(false);
}
return true;
}
return false;
}
示例8: dispatchKeyEvent
/**
* This should be called from the Activity's dispatchKeyEvent() to handle keyboard shortcuts.
*
* Note: dispatchKeyEvent() is called before the active view or web page gets a chance to handle
* the key event. So the keys handled here cannot be overridden by any view or web page.
*
* @param event The KeyEvent to handle.
* @param activity The ChromeActivity in which the key was pressed.
* @param uiInitialized Whether the UI has been initialized. If this is false, most keys will
* not be handled.
* @return True if the event was handled. False if the event was ignored. Null if the event
* should be handled by the activity's parent class.
*/
@SuppressFBWarnings("NP_BOOLEAN_RETURN_NULL")
public static Boolean dispatchKeyEvent(KeyEvent event, ChromeActivity activity,
boolean uiInitialized) {
int keyCode = event.getKeyCode();
if (!uiInitialized) {
if (keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_MENU) return true;
return null;
}
switch (keyCode) {
case KeyEvent.KEYCODE_SEARCH:
if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
activity.onMenuOrKeyboardAction(R.id.focus_url_bar, false);
}
// Always consume the SEARCH key events to prevent android from showing
// the default app search UI, which locks up Chrome.
return true;
case KeyEvent.KEYCODE_MENU:
if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
activity.onMenuOrKeyboardAction(R.id.show_menu, false);
}
return true;
case KeyEvent.KEYCODE_ESCAPE:
if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
if (activity.exitFullscreenIfShowing()) return true;
}
break;
case KeyEvent.KEYCODE_TV:
case KeyEvent.KEYCODE_GUIDE:
case KeyEvent.KEYCODE_DVR:
case KeyEvent.KEYCODE_AVR_INPUT:
case KeyEvent.KEYCODE_AVR_POWER:
case KeyEvent.KEYCODE_STB_INPUT:
case KeyEvent.KEYCODE_STB_POWER:
case KeyEvent.KEYCODE_TV_INPUT:
case KeyEvent.KEYCODE_TV_POWER:
case KeyEvent.KEYCODE_WINDOW:
// Do not consume the AV device-related keys so that the system will take
// an appropriate action, such as switching to TV mode.
return false;
}
return null;
}