Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    DrawLine not getting individual clicks even though setNoDoubleClicks is true

    I am using SmartGWT LGPL version 2025-01-14

    I would like to disable double-clicks in my application so I set setNoDoubleClicks to true in my DrawPane.
    I don't see a similar method on DrawLine.

    But, the setNoDoubleClicks does not seem to be working. I am still only getting one onClick call when I double click on the line. It should be called twice.

    See the attached test case.
    Attached Files

    #2
    Sorry, the noDoubleClicks feature is for Canvases only - it isn't available on DrawItems, and doesn't "cascade" downward from the parent Canvas (DrawPane).

    Comment


      #3
      It would be OK if I can process the double-click, but I don't see a double click handler on the DrawItem class. Is there a way to do that?

      Comment


        #4
        I think I found a reasonable solution - I can change to using a MouseDownHandler instead of a ClickHandler.
        Thanks for your help!

        Comment


          #5
          Unfortunately, using mouse down does not work well. It is getting called when the user presses the mouse to drag the window so I can't tell the difference between a drag and a click.
          So, I need DrawItem to either:
          1. Give me a way to process double-clicks instead of ignoring them, or
          2. Call onClick for every click, even if they are part of a double-click.

          Comment


            #6
            The event cycle of a click is mouseDown, mouseUp, click. So it seems like mouseUp is what you want, although you may need to set up to ignore the mouseUp at the end of a drag, if you don't want to treat that as a click.

            Comment


              #7
              I guess I can do this in my code. Seems like an oversight that the toolkit's Click Handler is absorbing double-clicks without any way to see that it did.

              Comment


                #8
                The latest nightly builds for SGWT 13.1+ now have double click support to DrawItems. See DrawItem.addDoubleClickHandler().

                Comment


                  #9
                  Thank you for doing that. I will test it soon.
                  I actually do not want double-clicks (I can handle calling my click code twice in my code), so I think it would be good to also add a setNoDoubleClicks method to DrawItem.
                  Thanks!

                  Comment


                    #10
                    Originally posted by Isomorphic View Post
                    The latest nightly builds for SGWT 13.1+ now have double click support to DrawItems.
                    There is a problem: If I implement both a single click and a doubleClick handler, the single click handler always gets called in addition to the double click one.
                    I think a double-click should only call the doubleClickHandler.

                    See the attached test case. Load it and double-click on the line.
                    Attached Files

                    Comment


                      #11
                      What you're seeing is actually the expected behavior. The problem is that to know that a click event is not part of a doubleClick event, you'd have to wait out the doubleClick delay before taking any action. So if your doubleClick delay were 500ms, say, then single click events would have to be delayed by 500ms to get the behavior you want.

                      That would create a slugglish UI experience, so software makers generally don't do it. Instead, if both click and doubleClick events are implemented for a particular target, the doubleClick is typically designed as an expanded action of the single click, so that there's no need to avoid the single click if it interaction turns out to be a doubleClick. For example, in Windows, if you click on a file in Windows Explorer, it will select the line, and if you doubleClick, it will execute the file (after the single click selects it).

                      So there's nothing for us to fix here. You just need to limit yourself to only one handler, for either click or doubleClick , or implement the doubleClick handler as an expanded action of the single click handler (as in the Windows example above).

                      Comment


                        #12
                        Originally posted by Isomorphic View Post
                        What you're seeing is actually the expected behavior
                        I see.

                        In that case, I think I would prefer having the ability to set no double-clicks so every click even in rapid succession are delivered to the onClick handler. But, no biggie, I can handle it in my code.

                        Thanks!

                        Comment

                        Working...
                        X