PDA

View Full Version : Odd problem with resizestate


mmenti
03-14-2006, 09:03 AM
Hi there,
I have a view that has both a dragstate and a resizestate. It contains a subview (in the bottom right corner). If there is a mousedown event on the subview, the parent view gets resized, and if there is a mousedown event on the parent view, the parent view gets dragged.

The aim is basically to resize the view if the user clicks somewhere near the bottom right corner, and drag it if the user clicks anywhere else.

It works, with one exception: for some reason, whenever the resizestate is applied, the "x" coordinate of the view is lost, and/or set to "0", so it jumps to the left, rather than being resized in place.

From debugging I can see that just before the resizestate is applied, the x value is OK, but inside the "onapply" event of the resizestate, the x value is 0. Changing it by force inside the "onapply" event doesn't seem to help, it's already moved at that point.

To illustrate, you can see an example here: http://www.msurveys.com/testcase/

Drag the rectangle, then click on the resize arrow in the bottom right corner -> the rectangle jumps back to the left.

Code for this simple test case is attached.

Any help/pointers appreciated!

Cheers,
Mario.

jstretch
03-14-2006, 10:39 AM
Just what I'm thinking: Whenever you are dragging, you have to tell the resize state to change its coordinates also. How to do this: I have no idea, but i'm fishing around with the Debugger.

jstretch
03-14-2006, 10:41 AM
Ultimately I think the solution is going to be ditching the resize state and simply doing the resizing in javascript...its not hard.

mmenti
03-15-2006, 12:42 AM
Thanks for your replies!

I actually just found a way to make it work, by removing the <simplelayout axis="x"/>. Seems it was this that caused the x coordinate to be set to 0 on resizestate.apply.

jstretch
03-15-2006, 04:21 AM
good work! I should have known.... =P