Gestures for Chrome 自定义使用

The?Gestures?for?Chrome?extension is designed to add mouse gesture support to Google?Chrome. It’s not well documented yet, but I put something on the previously blank?dev wiki. I’ll replicate that content here so I have it. By the way, my config is?here.

Adding a custom gesture

You can add?gestures?that run arbitrary javascript by selecting the “Run script …” option. This lets you do just about anything you can script!

Developing the script is fairly straightforward. You can write your script in a text editor and copy/paste into the script box, and it will remove the newlines automatically. Then click out of the text box, switch tab to a test page, reload, and try your new gesture out.

To debug it, use the Javascript console with?console.log().

To receive information about how and where your gesture was activated, use the?arg?parameter that your script is automatically passed. This parameter has four key members:

  • arg.action: Information about the action you scripted, including script name.
  • arg.config: Configuration of the?Chrome?Gesture extension itself
  • arg.event: The last MouseEvent that triggered this event.
  • arg.key: The gesture sequence written as a string, e.g. “LRDU”.

The arg.event is useful?for?finding find what you gestured over, because it includes the?srcElement?member. Therefore, the tag the gesture was run over is?arg.event.srcElement.

As an example, the following gesture will zoom in on an image:


Of course, your usual globals like?window?and?document?are also available, as shown in this “view?source” gesture code:

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理

相关文章

开始在上面输入您的搜索词,然后按回车进行搜索。按ESC取消。

返回顶部