Skip to content

Touch API proposal #103

@ystrot

Description

@ystrot
class Node {
  func onTouchPressed (_ f: (TouchEvent) -> ()) -> Disposable
  func onTouchMoved   (_ f: (TouchEvent) -> ()) -> Disposable
  func onTouchReleased(_ f: (TouchEvent) -> ()) -> Disposable
}

class TouchEvent : Event {
  let points: TouchPoint
}

class TouchPoint {
  let id: Int
  let location: Point
}
  1. Each touch point should have an identifier. iOS using timestamp, so just need to map it to an Int.
  2. When we pressed on a node, this node should receive all move and release events, even if such events occurs outside of this node.
  3. Note that we can't just route system touch events to a selected node. Here is an example:
    a. User pressed on the node1.
    b. User pressed on the node2.
    c. User moving both fingers. In this case system will send one touch event with two touches. However Macaw engine should send one event to node1 and another to node2.
  4. Make sure that if some node received onTouchPressed event, it should receive onTouchReleased at some point.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions