When the View opens the context menu, the mouse-down event is
already handled. Therefore, the next ACTION_UP should be canceled,
otherwise, single right click shows the context menu and then
invokes the normal click actions.
Also, the right-down event should always be consumed regardless
of the context menu support. "the right click opens the context
menu on some views, but it behaves as a normal click on some
other views" would confuse users.
Bug:
19641497
Change-Id: Ibbc18fe641745cf42382129b81858d8f3d14768b
* @hide
*/
protected boolean performButtonActionOnTouchDown(MotionEvent event) {
- if ((event.getButtonState() & MotionEvent.BUTTON_SECONDARY) != 0) {
- if (showContextMenu(event.getX(), event.getY(), event.getMetaState())) {
- return true;
- }
+ if (event.getToolType(0) == MotionEvent.TOOL_TYPE_MOUSE &&
+ (event.getButtonState() & MotionEvent.BUTTON_SECONDARY) != 0) {
+ showContextMenu(event.getX(), event.getY(), event.getMetaState());
+ mPrivateFlags |= PFLAG_CANCEL_NEXT_UP_EVENT;
+ return true;
}
return false;
}