About the event transfer mechanism ., Event transfer mechanism.

Source: Internet
Author: User

About the event transfer mechanism ., Event transfer mechanism.

Each ViewGroup includes onInterceptTouchEvent () and TouchEvent ()

Each View contains: TouchEvent ()

The event starts from the ViewGroup and passes to the ViewGroup or View.

The event cannot be passed down all the time, so onInterceptTouchEvent () is used to prevent the event from being passed like the following control.

Use TouchEvent () to prevent the event from being passed up TouchEvent. (If the return value is used, true indicates that the request has been consumed, and false indicates that the request is continuously transmitted)

For example, when the returned values are both false:

:

When the value of onInterceptTouchEvent () in LayoutView2 is true:


When both LayoutView2 Methods return true values:


Problem: We thought that only when false is returned can we avoid consuming events, so that the events can be passed between Down, Move, and Up. But this is not the case.

Each of the Down, Move, and Up events is an independent event entity. If the Down event cannot be consumed, the subsequent Move and Up events cannot be executed.



How does one understand the messaging and event-driven mechanisms of windows applications?

Windows applications are all message-driven (the so-called event. Any window can receive messages and make corresponding actions for each message.

Objective-c event Transfer Mechanism

Nsicationicationcenter can transmit messages
 

Related Article

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.