Announcement

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

    snapToGrid problem

    Hi,
    I'm using smartgwt 3.1p_2013-06-19 in Firefox 21.

    I have parent Canvas with setSnapHGap(150) and setSnapVGap(150) as a grid for snap Canvas with setSnapToGrid(true).

    When I try drag&drop the snap canvas over the parent, just a small movement (1-2 px) to jump to the next field bottom or right. But if I want to jump next field left or top, I need long mouse move.

    This behavior is very uncomfortable.

    Can I tune some parameters to improve this behavior?

    Here is full code exapmle:
    Code:
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.types.DragAppearance;
    import com.smartgwt.client.widgets.Canvas;
    
    
    public class SnapTest implements EntryPoint {
    
    	private int width = 150;
    	private int height = 150;
    	private Canvas parent;
    	private Canvas snap;
    
    	public void onModuleLoad() {
    		parent = new Canvas();
    		parent.setWidth100();
    		parent.setHeight100();
    		parent.setSnapHGap(width);
    		parent.setSnapVGap(height);
    		parent.draw();
    
    		drawGrid();
    
    		snap = new Canvas();
    		snap.setCanDragReposition(true);
    		snap.setDragAppearance(DragAppearance.TARGET);
    		snap.setBackgroundColor("red");
    		snap.setSnapToGrid(true);
    		snap.setWidth(width);
    		snap.setHeight(height);
    		snap.setParentElement(parent);
    		snap.moveTo(width, height);
    	}
    
    
    	private void drawGrid() {
    		Canvas cnv;
    		for (int curHeight = 0;(curHeight + height) < parent.getHeight(); curHeight += height) {
    			for (int curWidth = 0;(curWidth + width) < parent.getWidth(); curWidth += width) {
    				cnv = getCanvas();
    				cnv.moveTo(curWidth, curHeight);
    			}
    		}
    	}
    
    
    	private Canvas getCanvas() {
    		Canvas cnv = new Canvas();
    		cnv.setWidth(width);
    		cnv.setHeight(height);
    		cnv.setParentElement(parent);
    		cnv.setBorder("1px solid blue");
    
    		return cnv;
    	}
    }
Working...
X