Announcement

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

    Scrolling of DrawPane does not work correctly in v4.1

    This works correctly in v3.1 but seems to be broken in v4.1. I am working with the nightly build of each.

    The following code will show the problem. Click on a DrawRect and it should tell you which rectangle was clicked. Scroll a little bit horizontally and click on the same rectangle and it associates the click with the wrong rectangle. Try this with v3.1 and it works correctly.

    Code:
    package com.ft.ft.sandbox;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.types.Cursor;
    import com.smartgwt.client.types.Overflow;
    import com.smartgwt.client.widgets.Canvas;
    import com.smartgwt.client.widgets.drawing.DrawLabel;
    import com.smartgwt.client.widgets.drawing.DrawPane;
    import com.smartgwt.client.widgets.drawing.DrawRect;
    import com.smartgwt.client.widgets.drawing.events.ClickEvent;
    import com.smartgwt.client.widgets.drawing.events.ClickHandler;
    
    public class TestDrawRect implements EntryPoint {
    
    	@Override
    	public void onModuleLoad() {
    		DrawPane dp = new DrawPane();
    		dp.setWidth(500);
    		dp.setHeight(300);
    		dp.setBackgroundColor("#ADC2EB");
    		dp.setCursor(Cursor.ARROW);
    		
    		int leftCoord = 50;
    		int rectWidth = 50;
    		
    		for (int i=1; i<7; i++) {
    			DrawRect dr = new DrawRect();
    			dr.setWidth(rectWidth);
    			dr.setHeight(50);
    			dr.setTop(100);
    			dr.setLeft(leftCoord);
    			dr.setDrawPane(dp);
    			dr.setLineWidth(2);
    			dr.setLineColor("#000000");
    			dr.draw();
    			
    			DrawLabel dl = new DrawLabel();
    			dl.setContents(Integer.toString(i));
    			dl.setTop(120);
    			dl.setLeft(leftCoord + 20);
    			dl.setDrawPane(dp);
    			dl.draw();
    			
    			leftCoord += rectWidth + 10;
    			
    			final int rectNum = i;
    			dr.addClickHandler(new ClickHandler() {
    				@Override
    				public void onClick(ClickEvent event) {
    					System.err.println("Clicked on: " + rectNum);
    				}
    			});
    			
    			dl.addClickHandler(new ClickHandler() {
    				@Override
    				public void onClick(ClickEvent event) {
    					System.err.println("Clicked on: " + rectNum);
    				}
    			});
    		}
    		
    		Canvas c = new Canvas();
    		c.setWidth(400);
    		c.setHeight(300);
    		c.setTop(100);
    		c.setLeft(100);
    		c.setOverflow(Overflow.AUTO);
    		c.addChild(dp);
    		c.draw();
    	}
    }

    #2
    Thanks for reporting this with a clear test case. This is now fixed for tomorrow's builds (all affected versions).

    Comment

    Working...
    X