One way you COULD do this would be to add an override on the sublime-mousemap file. For example, the Default/Default (Linux).sublime-mousemap has this entry for double clicks:
{
"button": "button1", "count": 2,
"press_command": "drag_select",
"press_args": {"by": "words"}
},
However, the emphasis on COULD is because you SHOULD NOT do something like that unless you’re making the modification locally for your own use; the mouse map doesn’t include the ability to provide a context, which means that if you do this you’re stealing every double click everywhere all the time, whether it’s in your own custom file or not.
That means that (in this case) the user loses their ability to double click on text in order to select it. A potential solution to that would be to load all of the mouse maps, try to figure out exactly what would have happened if you hadn’t boosted the binding, and then do it if it’s not in your own file, but that’s a fair amount of work.
A potential workaround is something along the lines of this snippet:
class HyperhelpEventListener(sublime_plugin.EventListener):
def on_text_command(self, view, command, args):
if (view.is_read_only() and command == "drag_select" and
args.get("by", None) == "words"):
event = args["event"]
point = view.window_to_text((event["x"], event["y"]))
if view.match_selector(point, "text.hyperhelp meta.link"):
view.window().run_command("hyperhelp_navigate",
{"nav": "follow_link"})
return ("noop")
return None
This catches the text command that the default mouse map is triggering and checks the position the click happened at to see what to do. If the click is inside of a read only file on a help link, it dispatches a command to follow the link and then rewrites the text command to do nothing. Otherwise, it falls through and the command runs as normal.
In your case you would instead determine if the cursor is in a view of your own creation (possibly within the brackets or some such?) and trigger that way. Since you’re going to modify the buffer by changing the option, instead of invoking a command and then rewriting it to be noop, you could just rewrite the command to be your toggle command directly, since it would be a text command doing that.
This won’t work if the user has modified their own mouse map (or some other naughty package has done it for them) in a way that stops this command from being triggered, though.
I would recommend as a fall back you also have a key binding(s) for this, like for example Spacebar and/or Enter with a context that only triggers when the cursor is in an appropriate place, so that the user can use the keyboard as well, which will always work.
That’s just a good design idea in the general case, I think, since many people try to leave the mouse be as much as is possible and would probably thus welcome the ability to do this with a key binding as well.