Egret source code analysis - touch mechanism

Verbatim large column  https://www.dazhuanlan.com/2019/08/26/5d633573062d1/


Egret in touch mechanism

Since the last thing written Egret has been after a long time. In fact, long before the article written some, but there has been no order, it has not been made up. There are just two days time, on the next order.

Egret version used: 3.0.2.

Using the event bubbling mechanism adopted in Egret in (official has explained: Flash and the mechanism is similar).
There are three main stages of the event flow:

  1. Capture stage -> node
  2. Target node
  3. Bubbling node -> stage

A complete sequence of the event flow: the capture phase → → target stage bubbling phase. (Stage -> the Node -> Stage)
Egret touch event of default is bubbling. It can trigger, not saying we should touch points fall on the parent, as long as the target node point, you can press this rule to count

Add an event as follows:

1
addEventListener(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number)

Note: Egret framework of the flow of events and Flash implementation is not consistent.
In Flash, the default event listener will listen if open useCapture target and bubbling phases. If the monitor is turned capture will only capture but not the target of the event. In Egret, the goal of the event is included!

  1. About capture
    seCaptureu default is false: indicates the presence of only the target and bubbling phases.
    Set to true, it indicates that there is only the capture phase and the target phase (in Flash is not containing the target stage).
    If you call twice addEventListener, respectively seCapture set to true and false, then the target state will trigger twice callback

  2. About bubble
    1, bubble child transmission event, the parent does not capture the layers can be received, i.e. received in bubbling phase, sequentially from the inner to the outer (parent → child);
    2, the child does not transmit event bubbling only the parent capture, to receive, i.e. received in the acquisition phase, the order from outside to inside (parent → child);

Guess you like

Origin www.cnblogs.com/petewell/p/11410994.html