   updatePopulation()    
   
 doCanvasMouseDown = (e) ->
+  canvas.setCapture true
   e.preventDefault()
   [x,y] = getCanvasCursorPosition e, canvas
   unless (e.button is 0) and not e.shiftKey

    @timer = null
    @callback()

# ============ Bind Events =================
E("btn-reset").addEventListener "click", doReset
E("btn-step").addEventListener "click", doStep
#E("canvas").addEventListener "click", doCanvasClick
E("canvas").addEventListener "mousedown", doCanvasMouseDown, true
E("canvas").addEventListener "mouseup", doCanvasMouseUp
E("canvas").addEventListener "mousemove", doCanvasMouseMove, true
E("canvas").addEventListener "mousedrag", doCanvasMouseMove, true
E("btn-set-rule").addEventListener "click", doSetRule
E("btn-set-rule-generic").addEventListener "click", (e)->
  doSetRuleGeneric()

E('btn-disable-generic-rule').addEventListener 'click', doDisableGeneric
E('btn-export-close').addEventListener 'click', doExportClose
#initialize
if not E('generic-tf-code').value
  E('generic-tf-code').value = GENERIC_TF_TEMPLATE

