Hello!
For
- smartGWT 5.1p - v10.0p_2014-10-07/LGPL Development Only (built 2014-10-07)
- FF 31.5.0 (didn't test on other browsers)
Problem
When I'm resizing an Image by mouse drag, the new dimensions of the image are wrong when releasing the mouse button.
Description
To show what happens I created a class which adds an Image with two handlers that I need in my real code (DragResizeStop and Resized - in both these I will need to run some logic in my actual code). After DragResizeStop fires the Resized is fired and new values (different from what I would expect) for Width/Height are automatically applied to the object. To force the correct dimensions to be applied I set the Width/Height in the DragResizeStop with the values I take from the "event" object but they are overwritten automatically when the Resized triggers. The visual appearance of the Image is not modified but it's dimensions in pixels are wrong.
To exemplify I created the class below:
- Local image
- both handlers (DragResizeStop and Resized)
- added some logs
- in DragResizeStop I set the new Width and new Height from the "event" object to the Image and I print them in the logs
- when entering the Resized I just print the values from the Image object and they are different from the above ones.
What I would expect is that the Image's width/height are updated with the correct values when I release the mouse button - event.getNewWidth() and event.getNewHeight().
It seems that when the Resized is fired, some old (intermediate) values for W/H are applied and not the ones corresponding to the position where the mouse button was released.
Any thoughts? Have I misunderstand they way this works?
Thanks in advance!
P.S: same goes for DrawRect (I haven't tested for other draw items)
Running the code below, after a resize by mouse this is what I see in the logs:
For
- smartGWT 5.1p - v10.0p_2014-10-07/LGPL Development Only (built 2014-10-07)
- FF 31.5.0 (didn't test on other browsers)
Problem
When I'm resizing an Image by mouse drag, the new dimensions of the image are wrong when releasing the mouse button.
Description
To show what happens I created a class which adds an Image with two handlers that I need in my real code (DragResizeStop and Resized - in both these I will need to run some logic in my actual code). After DragResizeStop fires the Resized is fired and new values (different from what I would expect) for Width/Height are automatically applied to the object. To force the correct dimensions to be applied I set the Width/Height in the DragResizeStop with the values I take from the "event" object but they are overwritten automatically when the Resized triggers. The visual appearance of the Image is not modified but it's dimensions in pixels are wrong.
To exemplify I created the class below:
- Local image
- both handlers (DragResizeStop and Resized)
- added some logs
- in DragResizeStop I set the new Width and new Height from the "event" object to the Image and I print them in the logs
- when entering the Resized I just print the values from the Image object and they are different from the above ones.
What I would expect is that the Image's width/height are updated with the correct values when I release the mouse button - event.getNewWidth() and event.getNewHeight().
It seems that when the Resized is fired, some old (intermediate) values for W/H are applied and not the ones corresponding to the position where the mouse button was released.
Any thoughts? Have I misunderstand they way this works?
Thanks in advance!
P.S: same goes for DrawRect (I haven't tested for other draw items)
Running the code below, after a resize by mouse this is what I see in the logs:
Code:
11:39:13.332:MUP2:INFO:Log:+++++DragResizeStop (image): WxH - 346x203 11:39:13.332:MUP2:INFO:Log:+++++DragResizeStop (event): WxH - 346x203 11:39:13.338:MUP2:INFO:Log:*****Resized (image): WxH - 442x234
Code:
public class TestResize { public void drawDesign() { Layout mainLayout = new Layout(); mainLayout.setBorder("1px solid black"); DrawPane shapesPane = new DrawPane(); shapesPane.setCanDrag(true); shapesPane.setTop(0); shapesPane.setLeft(0); shapesPane.setWidth(1200); shapesPane.setHeight(800); shapesPane.setOverflow(Overflow.HIDDEN); final DrawImage image = new DrawImage(); image.setSrc("cow.jpg"); image.setTop(50); image.setLeft(50); image.setWidth(200); image.setHeight(200); image.showAllKnobs(); image.setDrawPane(shapesPane); image.setCanDrag(true); image.setShowResizeOutline(true); image.addDragResizeStopHandler(new DragResizeStopHandler() { @Override public void onDragResizeStop(DragResizeStopEvent event) { image.setWidth(event.getNewWidth()); image.setHeight(event.getNewHeight()); // here the correct values are applied on the Image SC.logInfo("+++++DragResizeStop (image): WxH - " + image.getWidth() + "x" + image.getHeight()); SC.logInfo("+++++DragResizeStop (event): WxH - " + event.getNewWidth() + "x" + event.getNewHeight()); } }); image.addResizedHandler(new ResizedHandler() { @Override public void onResized(ResizedEvent event) { // here some other values are present (old or intermediate ones) SC.logInfo("*****Resized (image): WxH - " + image.getWidth() + "x" + image.getHeight()); } }); image.draw(); shapesPane.draw(); mainLayout.addMember(shapesPane); } }
Comment