       @merging.x = pos.x
       @merging.y = pos.y
 
+    return
+
   mouseup: (pos) ->
+    if @dropdown_menu?
+      if @dropdown_menu.selected >= 0
+        @dropdown_menu.options[@dropdown_menu.selected].action(this)
+      @dropdown_menu = null
+      return
+
     if @selected?
       if Date.now() - @selected.t < 200
         mdx = pos.x - @selected.mx


    fn(this)

class NodeCollection
  constructor: (@shape) ->
    @nodes = []

    setStyle(ctx, node_style)
    ctx.beginPath()
    renderShape(ctx, @shape, default_node_radius)

    if @dropdown_menu?
      ctx.fillStyle = ctx.strokeStyle
      ctx.fill()
      ctx.restore()

      ctx.textAlign = 'start'
      ctx.textBaseline = 'top'

      for option, i in @dropdown_menu.options
        setStyle(ctx, menu_text_style)
        measure = ctx.measureText(option.name)
        ctx.fillStyle= if @dropdown_menu.selected == i then 'white' else 'black'
        ctx.fillRect(
          @dropdown_menu.pos.x,
          @dropdown_menu.pos.y + menu_text_height * (i+1),
          measure.width,
          menu_text_height)

        setStyle(ctx, if @dropdown_menu.selected == i
            menu_text_invert_style
          else
            menu_text_style)

        ctx.fillText(option.name,
          @dropdown_menu.pos.x,
          @dropdown_menu.pos.y + menu_text_height * (i+1))
    else
      ctx.stroke()
      ctx.restore()


  mousedown: (pos, idx) ->
    for n in @nodes
      if n.isHit(pos)
        if @merging?
