better event encapsulation, prohibit drag-and-drob event on scrollbars
This cleans up the dynamic event handler in canvas_events by adding three helpers:
- add_events: dynamically add events for an element which get remembered in the
current_events
variable. Does consistency check to make sure the events don't currently have a binding. - remove_events: remove events from the given element, also removing their references in
current_events
- init_events: bind events for an element that should hang around for the lifetime of the window
This makes it much easier to add a method to canvas_events. You can just define all the handlers you need as anonymous functions and use the current_events
variable to unbind.
The canvas_events.none
method automatically uses current_events to unbind. You can't currently stack events for multiple elements in current_events, but it doesn't look like we need that complexity anyway.
Going to go ahead and merge this since I merged a memory-leaking typo into master recently. Unfortunately, I didn't have my testing environment set up correctly so the error got through.