Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gesture dispatch. #4

Open
victorteokw opened this issue Mar 23, 2015 · 2 comments
Open

Gesture dispatch. #4

victorteokw opened this issue Mar 23, 2015 · 2 comments

Comments

@victorteokw
Copy link
Owner

How to dispatch gestures and clicks?
Does this work?
http://stackoverflow.com/questions/5931172/x-y-touch-coordinates-for-ios-mobile-devices

document.addEventListener('touchstart', function(e) {
    }, false);

    document.addEventListener('touchmove', function(e) {
        e.preventDefault();
    }, false);
@victorteokw
Copy link
Owner Author

The code for dispatch user events are

  setupEventDispatcher: () ->
    $body = $("body")
    events = ["touchstart", "touchmove", "touchend", "touchcancel",
      "mousemove", "mousedown", "mouseup"]
    for event in events
      block = (event) =>
        $body.on event, (e) =>
          this[event](e)
      block(event)

  mousedown: (e) ->
    layer = $(e.target)
    view = layer.data("view")
    while !view
      break if layer.is($(document))
      layer = layer.parent()
      view = layer.data("view")
    responder = view
    while responder && !responder.canBecomeFirstResponder()
      responder = responder.nextResponder()
    if responder
      event = new CB.Event
      event._timestamp = "ok"
      event._locationInWindow = new CB.Point(e.clientX, e.clientY)
      event._type = "mouse"
      event._view = view
      event._window = view.window
      responder.mouseDownWithEvent(event)

@victorteokw
Copy link
Owner Author

issues

  1. timestamp should be corrected by real timestamp
  2. only mouse down is implemented now, need to complete the whole implementation
  3. event type is not figured out, should discuss.
    should it be "mouse.down", "touch.end", "key.up" or "mouse", "touch"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant