       @setKeyView @oldKeyView
 
   setKeyView:(newKeyView)->
-    
+
     return if newKeyView is @keyView
 
     newKeyViewAcceptsKeyStatus = ()->

    @bindEvents()
    @setWindowProperties()
    super
  
  addLayer: (layer)->

    unless layer in @layers
      @layers.push layer
  
  removeLayer: (layer)->

    if layer in @layers
      index = @layers.indexOf(layer)
      @layers.splice index, 1
  
  bindEvents:()->

    $(window).bind "keydown keyup keypress",@key

      @keyView = newKeyView
      newKeyView?.propagateEvent KDEventType : 'KDViewBecameKeyView'
      @propagateEvent (KDEventType: 'WindowChangeKeyView', globalEvent : yes), view: newKeyView

  setDragView:(dragView)->

    @setDragInAction yes
    @dragView = dragView

  unsetDragView:(e)->

    @setDragInAction no
    @dragView.emit "DragFinished", e, @dragState
    @dragView = null


  redirectMouseMoveEvent:(event)->

    view = @dragView
    return unless @dragView

    {pageX, pageY}   = event
    {startX, startY} = view.dragState

    delta =
      x : pageX - startX
      y : pageY - startY

    view.drag event, delta

  getKeyView:()->
    @keyView

