Sublime Forum

Run command "drag_select" from a Text/WindowCommand?

#1

Anyone know the context of the “drag_select” command run in the mousemap files?
I’m working on a click-drag plugin, and the first thing I need to be able to do is allow for a normal click event to happen if there’s no selection. I can’t fire the ‘drag_select’ command, though.
Tried the following:

import sublime, sublime_plugin class DragSelectionCommand(sublime_plugin.TextCommand): def run(self, edit): self.view.run_command('drag_select') self.view.window().run_command('drag_select')

Not working and console has no output. Anyone else with experience? Perhaps the great jps or sublimator?

0 Likes

#2

drag_select is a view command, and requires an event argument to be passed, containing the cursor position and the pressed mouse button. If you implement run_ rather than run you will get access to the event (take a look through sublime_plugin.py in the same directory as the executable to see an example).

It’s also worth turning on command logging (via sublime.log_commands(True) ) to see the commands that normally get run.

That being said, I don’t think you’ll have much luck getting text dragging working via a plugin.

0 Likes