ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Mouse​Event​Listener

by SublimeText ST2/ST3

Adds on_pre_click and on_post_click callbacks to Sublime Text's plugin API.

Details

  • 2016.04.27.02.28.57
  • github.​com
  • github.​com
  • 1 year ago
  • 2 hours ago
  • 5 years ago

Installs

  • Total 938
  • Win 510
  • OS X 228
  • Linux 200
Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8 Sep 7 Sep 6 Sep 5 Sep 4 Sep 3
Windows 0 0 1 0 1 1 0 1 0 0 0 2 0 1 0 1 0 1 1 3 1 0 2 1 0 0 8 0 0 1 0 1 3 1 1 4 0 0 2 0 1 3 0 1 1
OS X 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 3 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0
Linux 0 0 1 0 0 1 0 0 0 0 2 0 0 1 0 1 0 0 1 0 1 1 2 0 0 0 0 0 0 0 0 0 2 3 0 1 0 0 0 0 1 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

MouseEventListener

MouseEventListener adds two new callbacks to Sublime Text 2's plugin API:

  • on_pre_click({'event': {'x': screen_x, 'y': screen_y, 'button': button}})
  • on_post_click(text_point)

An important thing to note is that the selection is modified not once but twice in between on_pre_mouse_down and on_post_mouse_down—this is done to determine the text_point of the click, as Sublime Text 2 has no API to translate a screen x and y into a text_point other than by calling drag_select and seeing where the selection ends up.

A second important thing to note is that mouse-up currently cannot be captured using Sublime Text 2's API. Hopefully this will be added in the future. However, this means that drags cannot be detected! other than perhaps by carefully monitoring the selection as it changes and just guessing. Additionally, on_selection_modified fires on mouse up in most cases.

Install

This plugin is available through Package Control, which is available here:

http://wbond.net/sublime_packages/package_control

As far as I know, Package Control does not handle dependencies, so if you depend on this package you may have to mention installing it in your install instructions.