     }
   }
 
+  let CLICK_RADIUS = 5
+  let CLICK_TIMESPAN = 150 // ms
+
+  func checkForClick(mouseDownEv: SDL_Event, mouseUpEv: SDL_Event) {
+    let d = mouseDownEv.button
+    let u = mouseUpEv.button
+    if (Int(u.timestamp) - Int(d.timestamp) <= CLICK_TIMESPAN) &&
+        u.clicks == 1 &&
+        (u.x >= d.x - CLICK_RADIUS) && (u.x <= d.x + CLICK_RADIUS) &&
+        (u.y >= d.y - CLICK_RADIUS) && (u.y <= d.y + CLICK_RADIUS) {
+      signal(.MouseClick, ev: mouseDownEv)
+      p("accepted the click", mouseDownEv.button)
+    }
+  }
+
   // Returns the id that can be used for removing the handler.
   public func on(eventType: SEventType, fn: SEventHandler) -> Int {
     var a = customEvents[eventType]

    mainDiv.expandWidth = true
    mainDiv.expandHeight = true

    try fn()
// SDL_StartTextInput()
// var textRect = SDL_Rect(x: 10, y: 10, w: 100, h: 30)

    _preventDefault = true
  }

  public mutating func stopPropagation() {
    _stopPropagation = true
  }

  public mutating func stopImmediatePropagation() {
    _stopImmediatePropagation = true
  }

  public static func new(ev: SDL_Event) -> SEvent {
    return SEvent(sdlEvent: ev, _preventDefault: false,
        _stopPropagation: false, _stopImmediatePropagation: false)
  }

}
