Prevent click events from being executed more than once in a short time

Source: Internet
Author: User

If there is a clickable control on the UI, and the control's click execution logic is expensive, there must be a need to prevent the control from being clicked more than once in a short period of time. Now common solutions are sorted as follows


1. Windows

Because WINODWS's click message is converted by mouse message, as long as the end of the onclick processing of all the mouse messages in the thread peek out.


2.android

as follows, it is usually done manually by setting the time flag, as shown in the link

Http://stackoverflow.com/questions/16534369/avoid-button-multiple-rapid-clicks

Another option to ban the control after a click practice is not available, as shown in the link

http://stackoverflow.com/questions/13912510/ How-can-avoid-firing-multiple-times-an-onclick-event-when-the-user-presses-the-b

I use it in practice when I click Post a delay runaable to do, if you receive a click then remove the previous runaable, and then post one out.

3.ios,

On the internet happened to see such a word, not personally tested

The UIApplication class has a ' beginignoringinteractionevents ' message, that can does this globally. That can is nice in times.


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.