I have a draggable label and I want to use the new position (left, top) when the drag ends. However I dont get the latest position, instead I get the previous location. For eg, when I drag for the first time, I see no change in the original left, right value. The label is moved to the new position, say p2.
The second drag moves from p2 to p3. However the DragRepositionStop handler still has the p2 values.
Is there a way to get the latest value in the handler? Should I use a different handler?
Env
eclipse 3.6
gwt 2.0.6
smartgwt 2.4
ie 7
The second drag moves from p2 to p3. However the DragRepositionStop handler still has the p2 values.
Is there a way to get the latest value in the handler? Should I use a different handler?
Env
eclipse 3.6
gwt 2.0.6
smartgwt 2.4
ie 7
Code:
package com.test.client; import com.smartgwt.client.types.Alignment; import com.smartgwt.client.types.DragAppearance; import com.smartgwt.client.types.Overflow; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.Window; import com.smartgwt.client.widgets.events.DragRepositionStopEvent; import com.smartgwt.client.widgets.events.DragRepositionStopHandler; import com.google.gwt.core.client.EntryPoint; /** * Entry point classes define <code>onModuleLoad()</code>. */ public class TestGwt implements EntryPoint { public void onModuleLoad() { Window window = new Window(); window.setHeight(300); window.setWidth(300); Canvas canvas = new Canvas(); window.addItem(canvas); canvas.addChild(getLabel()); window.show(); } private Canvas getLabel() { Label label = new Label(); label.setWidth(50); label.setHeight(50); label.setLeft(100); label.setTop(40); label.setBackgroundColor("yellow"); label.setAlign(Alignment.CENTER); label.setShowEdges(true); label.setOverflow(Overflow.HIDDEN); displayLabelPosition(label); label.setCanDragReposition(true); label.setDragAppearance(DragAppearance.OUTLINE); label.addDragRepositionStopHandler(getDragRepositionStopHandler()); return label; } private DragRepositionStopHandler getDragRepositionStopHandler() { return new DragRepositionStopHandler() { public void onDragRepositionStop(DragRepositionStopEvent event) { displayLabelPosition((Label) event.getSource()); } }; } private void displayLabelPosition(Label label) { label.setContents("l=" + label.getLeft() + " t=" + label.getTop()); } }
Comment