Android中的鼠标右键

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22692959/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 06:20:42  来源:igfitidea点击:

Right mouse button in Android

androidbuttonmouse

提问by eikuh

Since API 14, right mouse clicks should have been easy to detect via getButtonState().

从 API 14 开始,鼠标右键点击应该很容易通过 getButtonState() 检测到。

However, when I right-click, then it acts as the Back button. The middle button acts like the Home button. (Android 4.4, Galaxy Note 3, mouse via USB adapter)

但是,当我右键单击时,它充当后退按钮。中间按钮的作用类似于主页按钮。(Android 4.4,Galaxy Note 3,通过 USB 适配器的鼠标)

My question:

我的问题:

  • Does the (smartphone/tablet) device manufactor decide what to do with right button?
  • Or do different Android versions act differently?
  • What Android versions / devices support right/middle mouse button?
  • (智能手机/平板电脑)设备制造商是否决定如何使用右键?
  • 还是不同的 Android 版本有不同的表现?
  • 哪些 Android 版本/设备支持鼠标右键/中键?

回答by Zomby

The default behavior for the middle and right button are as you described for most devices, as is defined by the OS.

中键和右键的默认行为与您对大多数设备所描述的一样,由操作系统定义。

Starting at API level 14, there is a way to handle the second and third button from the MotionEvent of a GenericMotionListener.

从 API 级别 14 开始,有一种方法可以处理来自 GenericMotionListener 的 MotionEvent 的第二个和第三个按钮。

I suggest you have a look at the answers to this similar questionfor more details.

我建议您查看此类似问题的答案以了解更多详细信息。

回答by Aaron Gillion

The answer is yes, the manufacturer controls how the secondary/tertiary buttons react, because it is compiled with the kernel. Generically the right click acts as a back button, however, on a couple of my non-mainstream tablets it uses one of the mouse's side buttons to go back. Usually the wheel button goes home, all tested on my collection of devices. If you want to know how to override the default behavior, whether it be for an app or as a mod, check out my answer here: Change Mouse Right-click behavior

答案是肯定的,制造商控制二级/三级按钮如何反应,因为它是用内核编译的。通常,右键单击充当后退按钮,但是,在我的一些非主流平板电脑上,它使用鼠标的一个侧按钮返回。通常滚轮按钮会回家,所有这些都在我的设备集合上进行了测试。如果您想知道如何覆盖默认行为,无论是针对应用程序还是作为 mod,请在此处查看我的答案:更改鼠标右键单击行为

Hope this clears up everything

希望这能解决一切