5 Replies Latest reply on Sep 16, 2013 1:49 AM by AMULI

    Click versus MouseUp event

    Cari Jansen Adobe Community Professional

      This might seem a bizar question, but when I add a 'click' event versus a 'mouseup' event, I notice that in both cases (testing in Chrome), the assigned action doesn't occur until 'mouseup' ... that made me wonder why you'd use a 'click' over a 'mouseup' event? Is this related to device or browser support somehow?

       

      Just wondering

       

      Cari

      ...

      www.twitter.com/carijansen

        • 1. Re: Click versus MouseUp event
          sarhunt Adobe Employee

          Not bizarre at all! Totally valid question to ask.

           

          Let's use this scenario: I want to push a button, and as long as I'm holding the button I have a graphic of water filling up in a glass. When I stop holding, another animation plays to "splash" the water and stop it animating in. I would use a mouseup event to trigger that final splash animation.

           

          For most cases you can get away with a click, but if you want someone to "hold" then have something happen on release that's when you'd use a mouseup event.

           

          Sarah

          1 person found this helpful
          • 2. Re: Click versus MouseUp event
            Cari Jansen Adobe Community Professional

            Great example Sarah! Thanks!!!

             

            I think I'm going to rename the click 'click-n-hold' ;-)

             

            Can also see that for simple animations it doesn't necessarily matter which of the two is selected, as they both result in the action occuring ;-)

            • 3. Re: Click versus MouseUp event
              sarhunt Adobe Employee

              While we're at it, it'd be good to learn the difference between click and touch events (if you haven't brushed up already)

               

              Click vs. touchstart - these behave differently on desktop vs. mobile. If you need to duplicate functionality, a click will work probably 90% of the time. If you're making a mobile-focused project, be sure to use the touch events. Touchstart allows you to use multitouch (can't multitouch with click) and responds slightly faster than a click.

               

              themoreyouknow.jpg

               

              Sarah

              • 4. Re: Click versus MouseUp event
                Cari Jansen Adobe Community Professional

                 

                 

                and... 'the more you know' ... the more you realise there is to know & learn ... and share

                • 5. Re: Click versus MouseUp event
                  AMULI Level 4

                  Hi Cari,

                   

                  To complete Sarah's excellent illustration : a click is the succession of a mousedown and a mouseup.

                   

                  As a rule of thumb, avoid programming buttons on mousedown, but always prefer mouseup.

                   

                  If your user has clicked the button by mistake, a mousedown event handler will run, offering no recovery.

                   

                  By contrast, with a mouseup event handler, the user is offered the opportunity to move the pointer outside of the button, mouse button pressed, then release it without firing the event handler. User-friendly, isn't it

                   

                  Gil