backspaces/agentscript — pull request #68 by Caroisawesome (2014-11-01 02:19:46+00:00)
Title: Mouse events

Not yet to be merged! Also, this branches off of the evented PR (https://github.com/backspaces/agentscript/pull/63).
Work in progress, motivated by seismogram editing interface.

Notable changes:
* Added hitTest function in agent and link
* Added mixin Evented to agent, link, and patch
* Many additions to mouse.coffee for delegating mouse events.

Currently supports mousedown, mouseup, mousemove, mouseover, mouseout events. Dragstart, dragend, and drag are still in progress.

You can add event handlers to individual agents, patches, and links

agent.on('mousedown', callback)

or to all agents through their agentset

agents.on('mousedown', callback)

In both cases, the callback is passed an event object

{ target // the affected agent, patchX, patchY, originalEvent }

Test it out in sketches/mouseTest.html

Benny here: When writing functions that treat all agents equally regardless of breed, it's starting to get confusing that ABM.Agent is called ABM.Agent. For example, `delegateEventsToAllAgents()` is ambiguous. I vote we rename them to Turtles once and for all! (https://github.com/backspaces/agentscript/issues/47)