本文整理汇总了Java中android.view.MotionEvent.BUTTON_TERTIARY属性的典型用法代码示例。如果您正苦于以下问题:Java MotionEvent.BUTTON_TERTIARY属性的具体用法?Java MotionEvent.BUTTON_TERTIARY怎么用?Java MotionEvent.BUTTON_TERTIARY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.view.MotionEvent
的用法示例。
在下文中一共展示了MotionEvent.BUTTON_TERTIARY属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mouseEventToJavaModifiers
/**
* Takes an android mouse event and produces a Java InputEvent modifiers int which can be
* passed to vt320.
* @param mouseEvent The {@link MotionEvent} which should be a mouse click or release.
* @return A Java InputEvent modifier int. See
* http://docs.oracle.com/javase/7/docs/api/java/awt/event/InputEvent.html
*/
@TargetApi(14)
private static int mouseEventToJavaModifiers(MotionEvent mouseEvent) {
if (MotionEventCompat.getSource(mouseEvent) != InputDevice.SOURCE_MOUSE) return 0;
int mods = 0;
// See http://docs.oracle.com/javase/7/docs/api/constant-values.html
int buttonState = mouseEvent.getButtonState();
if ((buttonState & MotionEvent.BUTTON_PRIMARY) != 0)
mods |= 16;
if ((buttonState & MotionEvent.BUTTON_SECONDARY) != 0)
mods |= 8;
if ((buttonState & MotionEvent.BUTTON_TERTIARY) != 0)
mods |= 4;
// Note: Meta and Ctrl are intentionally swapped here to keep logic in vt320 simple.
int meta = mouseEvent.getMetaState();
if ((meta & KeyEvent.META_META_ON) != 0)
mods |= 2;
if ((meta & KeyEvent.META_SHIFT_ON) != 0)
mods |= 1;
if ((meta & KeyEvent.META_CTRL_ON) != 0)
mods |= 4;
return mods;
}
示例2: onDown
/**
* Called on onDown event.
* @param time The time stamp in millisecond of the event.
* @param x The x position of the event.
* @param y The y position of the event.
* @param fromMouse Whether the event originates from a mouse.
* @param buttons State of all buttons that are pressed.
*/
public void onDown(long time, float x, float y, boolean fromMouse, int buttons) {
resetResizeTimeout(false);
if (mNewTabButton.onDown(x, y)) {
mRenderHost.requestRender();
return;
}
final StripLayoutTab clickedTab = getTabAtPosition(x);
final int index = clickedTab != null
? TabModelUtils.getTabIndexById(mModel, clickedTab.getId())
: TabModel.INVALID_TAB_INDEX;
// http://crbug.com/472186 : Needs to handle a case that index is invalid.
// The case could happen when the current tab is touched while we're inflating the rest of
// the tabs from disk.
mInteractingTab = index != TabModel.INVALID_TAB_INDEX && index < mStripTabs.length
? mStripTabs[index]
: null;
boolean clickedClose = clickedTab != null
&& clickedTab.checkCloseHitTest(x, y);
if (clickedClose) {
clickedTab.setClosePressed(true);
mLastPressedCloseButton = clickedTab.getCloseButton();
mRenderHost.requestRender();
}
if (!mScroller.isFinished()) {
mScroller.forceFinished(true);
mInteractingTab = null;
}
if (fromMouse && !clickedClose && clickedTab != null
&& clickedTab.getVisiblePercentage() >= 1.f
&& (buttons & MotionEvent.BUTTON_TERTIARY) == 0) {
startReorderMode(time, x, x);
}
}
示例3: click
/**
* Called on click. This is called before the onUpOrCancel event.
* @param time The current time of the app in ms.
* @param x The x coordinate of the position of the click.
* @param y The y coordinate of the position of the click.
* @param fromMouse Whether the event originates from a mouse.
* @param buttons State of all buttons that were pressed when onDown was invoked.
*/
public void click(long time, float x, float y, boolean fromMouse, int buttons) {
resetResizeTimeout(false);
if (mNewTabButton.click(x, y) && mModel != null) {
if (!mModel.isIncognito()) mModel.commitAllTabClosures();
mTabCreator.launchNTP();
return;
}
final StripLayoutTab clickedTab = getTabAtPosition(x);
if (clickedTab == null || clickedTab.isDying()) return;
if (clickedTab.checkCloseHitTest(x, y)
|| (fromMouse && (buttons & MotionEvent.BUTTON_TERTIARY) != 0)) {
// 1. Start the close animation.
startAnimation(buildTabClosedAnimation(clickedTab), true);
// 2. Set the dying state of the tab.
clickedTab.setIsDying(true);
// 3. Fake a selection on the next tab now.
Tab nextTab = mModel.getNextTabIfClosed(clickedTab.getId());
if (nextTab != null) tabSelected(time, nextTab.getId(), clickedTab.getId());
// 4. Find out if we're closing the last tab. This determines if we resize immediately.
boolean lastTab = mStripTabs.length == 0
|| mStripTabs[mStripTabs.length - 1].getId() == clickedTab.getId();
// 5. Resize the tabs appropriately.
resizeTabStrip(!lastTab);
} else {
int newIndex = TabModelUtils.getTabIndexById(mModel, clickedTab.getId());
TabModelUtils.setIndex(mModel, newIndex);
}
}
示例4: onMouseEvent
/**
* @param event
* @param bridge
* @return True if the event is handled.
*/
@TargetApi(14)
private boolean onMouseEvent(MotionEvent event, TerminalBridge bridge) {
int row = (int) Math.floor(event.getY() / bridge.charHeight);
int col = (int) Math.floor(event.getX() / bridge.charWidth);
int meta = event.getMetaState();
boolean shiftOn = (meta & KeyEvent.META_SHIFT_ON) != 0;
vt320 vtBuffer = (vt320) bridge.buffer;
boolean mouseReport = vtBuffer.isMouseReportEnabled();
// MouseReport can be "defeated" using the shift key.
if (!mouseReport || shiftOn) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if (event.getButtonState() == MotionEvent.BUTTON_TERTIARY) {
// Middle click pastes.
pasteClipboard();
return true;
}
// Begin "selection mode"
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
closeSelectionActionMode();
}
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
// In the middle of selection.
if (selectionActionMode == null) {
selectionActionMode = startActionMode(new TextSelectionActionModeCallback());
}
int selectionStart = getSelectionStart();
int selectionEnd = getSelectionEnd();
if (selectionStart > selectionEnd) {
int tempStart = selectionStart;
selectionStart = selectionEnd;
selectionEnd = tempStart;
}
currentSelection = getText().toString().substring(selectionStart, selectionEnd);
}
} else if (event.getAction() == MotionEvent.ACTION_DOWN) {
terminalView.viewPager.setPagingEnabled(false);
vtBuffer.mousePressed(
col, row, mouseEventToJavaModifiers(event));
return true;
} else if (event.getAction() == MotionEvent.ACTION_UP) {
terminalView.viewPager.setPagingEnabled(true);
vtBuffer.mouseReleased(col, row);
return true;
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
int buttonState = event.getButtonState();
int button = (buttonState & MotionEvent.BUTTON_PRIMARY) != 0 ? 0 :
(buttonState & MotionEvent.BUTTON_SECONDARY) != 0 ? 1 :
(buttonState & MotionEvent.BUTTON_TERTIARY) != 0 ? 2 : 3;
vtBuffer.mouseMoved(
button,
col,
row,
(meta & KeyEvent.META_CTRL_ON) != 0,
(meta & KeyEvent.META_SHIFT_ON) != 0,
(meta & KeyEvent.META_META_ON) != 0);
return true;
}
return false;
}