"Android" touch-screen event delivery brief

Source: Internet
Author: User

A typical structural model

Activitya contains VIEWGROUPB,VIEWGROUPB containing VIEWC, where VIEWGROUPB (intermediate node) is selected as the current node perspective

Procedure one: The event relationship between the current node and the parent node

Activitya only cares about the Viewgroupb.ondispatchtouchevent return value, as long as B.ondispatchtouchevent () returns true during the Action_down distribution process, Then the subsequent events will be distributed to B. As for how VIEWGROUPB is handled in the Ondispatchtouchevent method, the parent node Activitya does not ask.

In other words, the parent node VIEWGROUPB the Action_down event to the Direct child node , and the child node responds with the return value of the Ondispatchtouchevent method, as long as the child node represents the ability to handle Action_down, The parent node then continues to hand over the subsequent events to the child nodes.

Procedure two: The event relationship between the current node and the child node

VIEWGROUPB The Action_down event is received from the previous level, onintercepttouchevent is called to determine whether to intercept. If not intercepted, then the process is consistent with the above "process one", if intercepted, then VIEWGROUPB will eat the event, directly ignore the VIEWC.

However, Onintercepttouchevent is an internal method, and the method itself does not affect the Ondispatchtouchevent return value of the current node.

Ondispatchtouchevent of the return value

Typically, the ondispatchtouchevent return value of a node is only related to the Ontouchevent return value of the current node and the Ondispatchtouchevent return value of the child node:

this.onDispatchTouchEventValue = child.onDispatchTouchEventValue || this.onTouchEvent

Of course, you can also force a return value to ondispatchtouchevent, however, it should not be forced to discard the original event mechanism, because the original event mechanism will be some state cleanup and other operations.

Action_down Example diagram:

Android Share Q Group: 315658668

"Android" touch-screen event delivery brief

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.