View Full Version : how does <dragstate/> call setX and setY?
girardjf
02-05-2003, 01:13 PM
I took a look at the dragstate.lzx file and did not see any methods used for calling setX and setY. Is it included elsewhere, or are they called via inheritance?
More importantly, is it called iteratively? And, if <dragstate/> calls setX and setY by default, are the newX and newY coordiantes of the parent view passed accordingly?
Thanks,
-justin
The "setY" and "setX" are implicit in the fact that
the attribute x and y have a "setter" function, as defined in the class definition. When the dragstate goes to modify the x or y attribute, the system uses the defined "setter" for the attribute.
I am not sure where setter functions are documented though. Anybody know?
<class name="dragstate" extends="state">
<attribute name="ydoffset" init="this.getMouse( 'y' )" />
<attribute name="y"
value="this.immediateParent.getMouse( 'y' ) - this.ydoffset" />
<attribute name="xdoffset" init="this.getMouse( 'x' )" />
<attribute name="x"
value="this.immediateParent.getMouse( 'x' ) - this.xdoffset" />
</class>
girardjf
02-05-2003, 01:43 PM
Thanks. So I guess no one knows where the setter function can be found?
My goal is to understand how the modifications are happening, so i can determine what i need to do to constrain drag coordinates for this project.
My assumption is that setX and setY are called iteratively, each time the coordinates change based on <dragstate/>. Is this the case? In addition, must i customize the setX and setY methods to reflect the constraints i want? This is my assumption.
Thanks again,
-justin
If you look at the example I gave of how the debugger dragging and resizing is implemented, I think that you can use that same mechanism.
See http://www.laszlosystems.com/developers/community/forums/showthread.php?s=&threadid=74
http://www.laszlosystems.com/developers/learn/documentation/lzxref/LzView.php#api
This documentation page on LzView describes its attributes and setter functions for them. The system
will automatically use the designated setter function when an attribute is modified, using setAttribute(). That is how things like animation and constraints work.
girardjf
02-05-2003, 03:33 PM
Thanks again!
A class's setters is a table that says 'this attribute is set by this method.' To change the way an attribute is set, you can use the attribute tag -- e.g.
<class name="myclass>
<attribute name="x" onset="this.specialF( x )"/>
Note that in the context of an onset handler, the value for the attribute is bound to the attribute name.
As for limiting drag, you could override setX and setY, or you could create your own drag state that used Math.min and Math.max to set the values for the constraints. You can see the code for the dragstate in WEB-INF/lps/components/utils/states
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.