Announcement

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

    Wrong ClickHandler called after panning DrawPane

    This is very strange. If you go to https://dev.3dmathpuzzles.com/3dmp/D...itherlink.html

    If you click on any line, it will change state in cycle from solid black -> dotted gray -> solid gray.
    If you click on any of the shapes, it will change state in cycle from yellow -> blue -> white.

    It works perfectly until you pan the window.

    For example, if you pan the window all the way up and click on the top left box, it changes the state of a line or box below it.

    This is very strange. My code does nothing more than adding DrawItems to the DrawPane and attaching a ClickHandler to each one.

    Do I need to call something after panning the DrawPane?

    #2
    Here is a screenshot of what I am seeing. Pan the window all the way to the top and then:

    Click image for larger version

Name:	screenshot.png
Views:	30
Size:	69.5 KB
ID:	274439

    I can try to boil my code down to a test case if that will help.

    Comment


      #3
      This sounds like your click handler just isn't taking account of the pan when it tries to determine what box was hit. But you didn't share the code, so we can't help further.

      Comment


        #4
        Originally posted by Isomorphic View Post
        This sounds like your click handler just isn't taking account of the pan when it tries to determine what box was hit
        There are separate ClickHandlers on each DrawItem, not one common shared one.

        Originally posted by Isomorphic View Post
        you didn't share the code, so we can't help further.
        I will boil it down to a test case and post that.

        Comment


          #5
          Oh, if this is a ClickHandler specifically on a DrawItem, then yes, it should fire consistently when panned.

          A test case would be great. Please make sure to mention the browser(s) where you are seeing the problem, and your exact product edition and version.

          Comment


            #6
            I am using smartgwt-lgpl version 13.1-p20241221 My browser is Chrome Version 131.0.6778.205 (Official Build) (64-bit) on Windows 11 Home 24H2.

            I created a test case. You can try it here: https://dev.3dmathpuzzles.com/3dmp/D...therlink2.html
            If you click on any box, it will change color.
            If you scroll the window all the way to the bottom and click on any of the boxes close to the top, the color on a different box which is lower changes.

            Here is my EntryPoint class:
            Code:
            package com._3dmathpuzzles.gwt.client;
            
            import com.google.gwt.core.client.EntryPoint;
            import com.smartgwt.client.widgets.drawing.DrawPane;
            
            public class DiagonalSlitherlink2 implements EntryPoint {
              private DrawPane drawPane;
            
              public void onModuleLoad() {
                drawPane = new DrawPane();
                DiagonalSlitherlinkDrawHandler2 drawHandler = new DiagonalSlitherlinkDrawHandler2(drawPane);
                drawPane.addDrawHandler(drawHandler);
                drawPane.setCanDragScroll(true);
                drawPane.setHtmlElement("gwt");
                drawPane.setMatchElement(true);
                drawPane.draw();
              }
            }
            Here is the draw handler:
            Code:
            package com._3dmathpuzzles.gwt.client;
            
            import com.smartgwt.client.widgets.drawing.DrawPane;
            import com.smartgwt.client.widgets.drawing.DrawPolygon;
            import com.smartgwt.client.widgets.drawing.Point;
            import com.smartgwt.client.widgets.events.DrawEvent;
            import com.smartgwt.client.widgets.events.DrawHandler;
            
            public class DiagonalSlitherlinkDrawHandler2 implements DrawHandler {
              private DrawPane drawPane;
            
              public DiagonalSlitherlinkDrawHandler2(DrawPane drawPane) {
                this.drawPane = drawPane;
              }
            
              public void onDraw(DrawEvent event) {
                for( int x=0; x<10; x++ ) {
                  for( int y=0; y<10; y++) {
                    DrawPolygon drawPolygon = new DrawPolygon();
                    drawPolygon.addClickHandler(new BoxClickHandler2(drawPolygon));
                    drawPolygon.setDrawPane(drawPane);
                    Point[] drawPoints = new Point[4];
                    drawPoints[0] = new Point(x*100,y*100);
                    drawPoints[1] = new Point((x+1)*100,y*100);
                    drawPoints[2] = new Point((x+1)*100,(y+1)*100);
                    drawPoints[3] = new Point(x*100,(y+1)*100);
                    drawPolygon.setPoints(drawPoints);
                    setBoxColor(drawPolygon);
                    drawPolygon.draw();
                  }
                }
              }
            
              public static void setBoxColor(DrawPolygon drawPolygon) {
                int color = (int)(Math.random()*0xffffff);
                drawPolygon.setFillColor("#"+Integer.toHexString(color));
              }
            }
            Here is the Click Handler:
            Code:
            package com._3dmathpuzzles.gwt.client;
            
            import com.smartgwt.client.widgets.drawing.DrawPolygon;
            import com.smartgwt.client.widgets.drawing.events.ClickEvent;
            import com.smartgwt.client.widgets.drawing.events.ClickHandler;
            
            public class BoxClickHandler2 implements ClickHandler {
              private DrawPolygon drawPolygon;
            
              public BoxClickHandler2(DrawPolygon drawPolygon) {
                this.drawPolygon = drawPolygon;
              }
            
              public void onClick(ClickEvent event) {
                DiagonalSlitherlinkDrawHandler2.setBoxColor(drawPolygon);
              }
            }
            Please let me know if you need anything else.
            Last edited by NeilAgg; 28 Dec 2024, 10:09.

            Comment


              #7
              Can you reproduce this without using setHtmlElement()? Because that introduces a lot of additional complexity - coordinates then have to be computed relative to a DOM element, and then we are dealing with the hundreds of bugs in DOM coordinate reporting.

              Also, just in terms of having the best chance of having this looked at, the ideal test case is a single file that we can just drop into a standard test project and run. So that's another reason to eliminate use of setHtmlElement(), and then to convert to inner classes or just drop some of the code that isn't actually relevant to the possible framework bug.

              That's your best shot of getting this looked at instead of it sitting in the queue, never quite making it to the top!

              Comment


                #8
                I changed it to not use setHtmlElement() and moved everything into one file.
                You can see it here: https://dev.3dmathpuzzles.com/SmartGwtTest/test.html

                I am attaching the code file.
                Attached Files

                Comment


                  #9
                  Isomorphic were you able to confirm this is a bug?

                  Comment


                    #10
                    Hi Neil
                    Yes this appears to be a real issue. It is assigned for investigation and we'll follow up when we have more information for you

                    Regards
                    Isomorphic Software

                    Comment


                      #11
                      Originally posted by Isomorphic View Post
                      this appears to be a real issue. It is assigned for investigation
                      Thanks for confirming and glad it is being worked on. I am willing to wait. Please let me know if you need anything from me.

                      Comment


                        #12
                        We've now made some changes to address this issue to branches 13.0 and above.
                        Please try the next nightly build, dated Jan 14 (or above) to see the changes and let us know if you continue to encounter problems.

                        Thanks and Regards
                        Isomorphic Software

                        Comment


                          #13
                          Originally posted by Isomorphic View Post
                          Please try the next nightly build, dated Jan 14 (or above) to see the changes
                          It seems to be working well now. Thank you!

                          Comment

                          Working...
                          X