while (i.hasNext()) {
CanvasLayer layer = (CanvasLayer) i.next();
// Process on this layer only if it implements EventAccepter
if (layer instanceof EventAcceptor) {
EventAcceptor acceptor = (EventAcceptor) layer;
// Set the layer source to the layer, then
// pass the event to that layer
event.setLayerSource(layer);
acceptor.dispatchEvent(event);
// stop if the event was consumed
if (event.isConsumed()) {
break;
}