jakevdp/mpld3 — pull request #96 by jakevdp (2014-03-17 21:03:25+00:00)
Title: ENH: make conflicting buttons automatically deactivate each other

I changed the ``ButtonFactory`` code so that some of the actions are more automatic. In particular, I added the following attributes:

- ``actions``: a list of arbitrary string identifiers, such as ["drag", "scroll"]. Any time a button is activated, other buttons with any common identifiers are automatically deactivated.

- ``sticky``: a boolean telling whether the button should stay down when pressed

- ``onActivate``/``onDeactivate``/``onDraw``: these methods are meant to be overridden by the class, while ``activate``/``deactivate`` are boilerplate functions which make sure button highlighting, stickiness, etc. work as promised.

I also modified ``examples/box_zoom.py`` and ``examples/linked_brush.py`` to work with this.

Note that if you try to use box zoom and linked brush at the same time, strange things will happen. This is because d3 provides no way to add a custom class to brush objects; I need to think about a way to work around that. That issue is one of the final blockers to pushing these plugins into the main repository.