Is setAttribute on foo always guaranteed to remove a pre-existing constraint on foo?
On Sat, Jan 10, 2009 at 4:41 PM, P T Withington <[email protected]> wrote: > The fact that it won't let you say 'this' in an initial value, might be a > bug in the tag compiler... But maybe it is not: you shouldn't really be > able to refer to other attributes when declaring an initial value, since you > don't know what order those initializations happen in. > > I guess what you really have to do is put a handler in: > > <resizestate ... > <!-- on resize, stop constraining position --> > <handler name="onapply"> > this.setAttribute('x', this.x); > this.setAttribute('y', this.y); > </handler> > > > On 2009-01-10, at 16:34EST, P T Withington wrote: > >> Ouch. Does it work if you leave out the this? >> >> On 2009-01-10, at 16:26EST, Henry Minsky wrote: >> >>> Say, that attribute value gives a compilation error in swf9 >>> >>> <attribute name="x" value="this.x" /> >>> >>> >>> >>> .openlaszlo.sc.CompilerError: debugger/debugger.lzx: 232: Error: The >>> this keyword can not be used in static methods. It can only be used in >>> instance methods, function closures, and global code, in line: , >>> active: false, id: "_dbg_cmd_complete_tab", key: ["tab"]}, "class": >>> $lzc$class_$m518}, {attrs: {$classrootdepth: 1, name: "drag"}, >>> "class": $lzc$class_dragstate}, {attrs: {$classrootdepth: 1, name: >>> "resize", x: this.x, y: this.y}, "class": $lzc$class_resizestate}, >>> {attrs: {$classrootdepth: 1, axis: "y"}, "class": >>> $lzc$class_resizelayout}, {attrs: {$classrootdepth: 1, $delegates: >>> ["oninit", "$lzc$handle_oninit$$debugger$2Fdebugger$2Elzx_615_49_$m349", >>> null], background: void 0, clip: true, controls: void 0, height: 24, >>> logo: void 0, name: "top", pixellock: true, title: void 0, width: new >>> LzAlwaysExpr("$lzc$bind_width$$debugger$2Fdebugger$2Elzx_615_49_$m345", >>> "$lzc$dependencies_width$$debugger$2Fdebugger$2Elzx_615_49_$m345")}, >>> "class": $lzc$class_$m519}, {attrs: {$classrootdepth: 1, content: void >>> 0, left: void 0, name: "middle", options: {releasetolayout: true}, >>> pixellock: true, right: void 0, width: new >>> LzAlwaysExpr("$lzc$bind_width$$debugger$2Fdebugger$2Elzx_670_92_$m406", >>> "$lzc$dependencies_width$$debugger$2Fdebugger$2Elzx_670_92_$m406")}, >>> "class": $lzc$class_$m528}, {attrs: {$classrootdepth: 1, $delegates: >>> ["onmousedown", >>> "$lzc$handle_onmousedown$$debugger$2Fdebugger$2Elzx_710_26_$m424", >>> null], bottomright: void 0, center: void 0, clickable: true, height: >>> new >>> LzAlwaysExpr("$lzc$bind_height$$debugger$2Fdebugger$2Elzx_710_26_$m423", >>> "$lzc$dependencies_height$$debugger$2Fdebugger$2Elzx_710_26_$m423"), >>> left: void 0, name: "bottom", pixellock: true, splitter: void 0, >>> width: new >>> LzAlwaysExpr("$lzc$bind_width$$debugger$2Fdebugger$2Elzx_710_26_$m422", >>> "$lzc$dependencies_width$$debugger$2Fdebugger$2Elzx_710_26_$m422")}, >>> "class": $lzc$class_$m532}, {attrs: {$classrootdepth: 1, opacity: >>> 0.75, options: {ignorelayout: true}, pixellock: true, width: new >>> LzAlwaysExpr("$lzc$bind_width$$debugger$2Fdebugger$2Elzx_831_61_$m504", >>> "$lzc$dependencies_width$$debugger$2Fdebugger$2Elzx_831_61_$m504"), y: >>> new LzAlwaysExpr("$lzc$bind_y$$debugger$2Fdebugger$2Elzx_831_61_$m508", >>> "$lzc$dependencies_y$$debugger$2Fdebugger$2Elzx_831_61_$m508")}, >>> "class": $lzc$class_$m544}, {attrs: {$classrootdepth: 1, height: new >>> LzAlwaysExpr("$lzc$bind_height$$debugger$2Fdebugger$2Elzx_833_69_$m509", >>> "$lzc$dependencies_height$$debugger$2Fdebugger$2Elzx_833_69_$m509"), >>> opacity: 0.75, options: {ignorelayout: true}, pixellock: true, x: new >>> LzAlwaysExpr("$lzc$bind_x$$debugger$2Fdebugger$2Elzx_833_69_$m510", >>> "$lzc$dependencies_x$$debugger$2Fdebugger$2Elzx_833_69_$m510")}, >>> "class": $lzc$class_$m545}], LzView["children"]);public static var >>> attributes = new LzInheritedHash(LzView.attributes);public function >>> $lzc$bind_x$$debugger$2Fdebugger$2Elzx_107_49_$m284 ($lzc$ignore_$1) { >>> debugger/debugger.lzx: 232: Error: The this keyword can not be used in >>> static methods. It can only be used in instance methods, function >>> closures, and global code, in line: , active: false, id: >>> "_dbg_cmd_complete_tab", key: ["tab"]}, "class": $lzc$class_$m518}, >>> {attrs: {$classrootdepth: 1, name: "drag"}, "class": >>> $lzc$class_dragstate}, {attrs: {$classrootdepth: 1, name: "resize", x: >>> this.x, y: this.y}, "class": $lzc$class_resizestate}, {attrs: >>> {$classrootdepth: 1, axis: "y"}, "class": $lzc$class_resizelayout}, >>> {attrs: {$classrootdepth: 1, $delegates: ["oninit", >>> "$lzc$handle_oninit$$debugger$2Fdebugger$2Elzx_615_49_$m349", null], >>> background: void 0, clip: true, controls: void 0, height: 24, logo: >>> void 0, name: "top", pixellock: true, title: void 0, width: new >>> LzAlwaysExpr("$lzc$bind_width$$debugger$2Fdebugger$2Elzx_615_49_$m345", >>> "$lzc$dependencies_width$$debugger$2Fdebugger$2Elzx_615_49_$m345")}, >>> "class": $lzc$class_$m519}, {attrs: {$classrootdepth: 1, content: void >>> 0, left: void 0, name: "middle", options: {releasetolayout: true}, >>> pixellock: true, right: void 0, width: new >>> LzAlwaysExpr("$lzc$bind_width$$debugger$2Fdebugger$2Elzx_670_92_$m406", >>> "$lzc$dependencies_width$$debugger$2Fdebugger$2Elzx_670_92_$m406")}, >>> "class": $lzc$class_$m528}, {attrs: {$classrootdepth: 1, $delegates: >>> ["onmousedown", >>> "$lzc$handle_onmousedown$$debugger$2Fdebugger$2Elzx_710_26_$m424", >>> null], bottomright: void 0, center: void 0, clickable: true, height: >>> new >>> LzAlwaysExpr("$lzc$bind_height$$debugger$2Fdebugger$2Elzx_710_26_$m423", >>> "$lzc$dependencies_height$$debugger$2Fdebugger$2Elzx_710_26_$m423"), >>> left: void 0, name: "bottom", pixellock: true, splitter: void 0, >>> width: new >>> LzAlwaysExpr("$lzc$bind_width$$debugger$2Fdebugger$2Elzx_710_26_$m422", >>> "$lzc$dependencies_width$$debugger$2Fdebugger$2Elzx_710_26_$m422")}, >>> "class": $lzc$class_$m532}, {attrs: {$classrootdepth: 1, opacity: >>> 0.75, options: {ignorelayout: true}, pixellock: true, width: new >>> LzAlwaysExpr("$lzc$bind_width$$debugger$2Fdebugger$2Elzx_831_61_$m504", >>> "$lzc$dependencies_width$$debugger$2Fdebugger$2Elzx_831_61_$m504"), y: >>> new LzAlwaysExpr("$lzc$bind_y$$debugger$2Fdebugger$2Elzx_831_61_$m508", >>> "$lzc$dependencies_y$$debugger$2Fdebugger$2Elzx_831_61_$m508")}, >>> "class": $lzc$class_$m544}, {attrs: {$classrootdepth: 1, height: new >>> LzAlwaysExpr("$lzc$bind_height$$debugger$2Fdebugger$2Elzx_833_69_$m509", >>> "$lzc$dependencies_height$$debugger$2Fdebugger$2Elzx_833_69_$m509"), >>> opacity: 0 >>> >>> >>> On Sat, Jan 10, 2009 at 4:23 PM, Henry Minsky <[email protected]> >>> wrote: >>>> >>>> Yes, that is what I was looking for. >>>> >>>> >>>> On Sat, Jan 10, 2009 at 4:17 PM, P T Withington <[email protected]> >>>> wrote: >>>>> >>>>> I think a better way, might be to leave the constraints as the default >>>>> for x >>>>> and y, and in the resize state say: >>>>> >>>>> <class ... >>>>> x="${canvas.width * .95 - this.width}" y ="${canvas.height * .95 - >>>>> this.height}" >>>>> ...> >>>>> <resizestate name="resize"> >>>>> <!-- on resize, stop constraining position --> >>>>> <attribute name="x" value="this.x" /> >>>>> <attribute name="y" value="this.y" /> >>>>> </resizestate> >>>>> >>>>> The intent is, that as soon as you start resizing, x and y get set to >>>>> their >>>>> current value, which will remove the default constraint. (This is how >>>>> states are defined to work. If a state defines an attribute that is >>>>> already >>>>> defined in the parent, the attribute is given the state value. When >>>>> the >>>>> state is removed, the attribute keeps it's last value.) >>>>> >>>>> On 2009-01-09, at 20:59EST, Henry Minsky wrote: >>>>> >>>>>> Here's a method I am using to remove the constraint when you start >>>>>> resizing the width/height; I put the x,y constraints into a method >>>>>> that is applied by default, and then when the resize state is applied, >>>>>> it un-applies that initial state. i.e., >>>>>> >>>>>> <class name="LzDebugWindow"> >>>>>> >>>>>> <!-- sets the initial position of the debug window to constrain to the >>>>>> canvas> >>>>>> <state name="initial_position_state" applied="true"> >>>>>> <attribute name="y" value="${canvas.height * .95 - this.height}"/> >>>>>> <attribute name="x" value="${canvas.width * .95 - this.width}"/> >>>>>> </state> >>>>>> >>>>>> >>>>>> <resizestate name="resize"> >>>>>> <handler name="onapplied"> >>>>>> parent.initial_position_state.setAttribute('applied', false); >>>>>> </handler> >>>>>> </resizestate> >>>>>> </class> >>>>>> >>>>>> Is there a better way to do this? >>>>>> >>>>>> >>>>>> On Fri, Jan 9, 2009 at 6:43 PM, Henry Minsky >>>>>> <[email protected]> >>>>>> wrote: >>>>>>> >>>>>>> Oh hey, there is definitely a bug when you try to resize the debugger >>>>>>> window; the constraints >>>>>>> don't let go! >>>>>>> >>>>>>> Tucker, what is the right way to disable the constraint on x and y >>>>>>> when the user wants to change >>>>>>> the width and height manually? >>>>>>> >>>>>>> I wonder if the constraints on x and y should be in a state, and then >>>>>>> the state could be unapplied >>>>>>> when the user activates the resizer state? >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Fri, Jan 9, 2009 at 6:26 PM, Henry Minsky >>>>>>> <[email protected]> >>>>>>> wrote: >>>>>>>> >>>>>>>> I don't see the error when I run in swf8 in FF3 on OSX. >>>>>>>> >>>>>>>> It might be possible that some other example in the doc web page is >>>>>>>> causing the >>>>>>>> network to get broken somehow? Can you run that example just >>>>>>>> standalone as an app >>>>>>>> and see if you still see the error behavior? >>>>>>>> >>>>>>>> >>>>>>>> On Fri, Jan 9, 2009 at 4:30 PM, Lou Iorio <[email protected]> >>>>>>>> wrote: >>>>>>>>> >>>>>>>>> I'm not running a test case, just building the documentation, >>>>>>>>> but here's the example. >>>>>>>>> >>>>>>>>> <canvas debug="true" height="200" width="100%"> >>>>>>>>> <debug x="160" y="5" height="150" width="300"/> >>>>>>>>> <script>Debug.debug('user code');</script> >>>>>>>>> <button text="Get x, y" width="150" height="150" >>>>>>>>> onclick="Debug.debug('click: x=%d, y=%d', getMouse('x'), >>>>>>>>> getMouse('y'))"/> >>>>>>>>> </canvas> >>>>>>>>> >>>>>>>>> >>>>>>>>> On Jan 9, 2009, at 5:18 PM, Henry Minsky wrote: >>>>>>>>> >>>>>>>>>> Can you send me the lzx test case code you're running? >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On Fri, Jan 9, 2009 at 2:49 PM, Lou Iorio >>>>>>>>>> <[email protected]> >>>>>>>>>> wrote: >>>>>>>>>>> >>>>>>>>>>> I'm seeing some odd behavior on the Mac with FF3. >>>>>>>>>>> >>>>>>>>>>> When I first load a chapter, say Debugging, the example comes up >>>>>>>>>>> like >>>>>>>>>>> this: >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> And the FF status bar says: "Transferring data from >>>>>>>>>>> localhost...", >>>>>>>>>>> and that message doesn't go away. >>>>>>>>>>> >>>>>>>>>>> If I then click the refresh button, the example comes up like >>>>>>>>>>> this: >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> And the FF status bar says: "Done". >>>>>>>>>>> >>>>>>>>>>> Safari 3.2.1 on the Mac seems to do the right thing. >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> On Jan 9, 2009, at 1:33 PM, Henry Minsky wrote: >>>>>>>>>>> >>>>>>>>>>>> please review , check that the debugger shows up on canvas in >>>>>>>>>>>> doc >>>>>>>>>>>> examples >>>>>>>>>>>> thanks >>>>>>>>>>>> >>>>>>>>>>>> ---------- Forwarded message ---------- >>>>>>>>>>>> From: Henry Minsky <[email protected]> >>>>>>>>>>>> Date: Fri, Jan 9, 2009 at 12:27 PM >>>>>>>>>>>> Subject: For Review: Change 20090109-hqm-3 Summary: make >>>>>>>>>>>> debugger >>>>>>>>>>>> set >>>>>>>>>>>> position to be on screen >>>>>>>>>>>> To: [email protected] >>>>>>>>>>>> Cc: [email protected] >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> Change 20090109-hqm-3 by [email protected] on 2009-01-09 >>>>>>>>>>>> 12:26:42 >>>>>>>>>>>> EST >>>>>>>>>>>> in /Users/hqm/openlaszlo/trunk5 >>>>>>>>>>>> for http://svn.openlaszlo.org/openlaszlo/trunk >>>>>>>>>>>> >>>>>>>>>>>> Summary: make debugger set position to be on screen >>>>>>>>>>>> >>>>>>>>>>>> New Features: >>>>>>>>>>>> >>>>>>>>>>>> Bugs Fixed: LPP-7602 >>>>>>>>>>>> >>>>>>>>>>>> Technical Reviewer: ptw >>>>>>>>>>>> QA Reviewer: (pending) >>>>>>>>>>>> Doc Reviewer: (pending) >>>>>>>>>>>> >>>>>>>>>>>> Documentation: >>>>>>>>>>>> >>>>>>>>>>>> Release Notes: >>>>>>>>>>>> >>>>>>>>>>>> Details: >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> Tests: >>>>>>>>>>>> >>>>>>>>>>>> make test/hello.lzx canvas size small (200 x 500) and see that >>>>>>>>>>>> debugger still appears on the canvas >>>>>>>>>>>> >>>>>>>>>>>> Files: >>>>>>>>>>>> M lps/components/debugger/debugger.lzx >>>>>>>>>>>> >>>>>>>>>>>> Changeset: >>>>>>>>>>>> http://svn.openlaszlo.org/openlaszlo/patches/20090109-hqm-3.tar >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> -- >>>>>>>>>>>> Henry Minsky >>>>>>>>>>>> Software Architect >>>>>>>>>>>> [email protected] >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> Henry Minsky >>>>>>>>>> Software Architect >>>>>>>>>> [email protected] >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> Henry Minsky >>>>>>>> Software Architect >>>>>>>> [email protected] >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> Henry Minsky >>>>>>> Software Architect >>>>>>> [email protected] >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Henry Minsky >>>>>> Software Architect >>>>>> [email protected] >>>>> >>>>> >>>> >>>> >>>> >>>> -- >>>> Henry Minsky >>>> Software Architect >>>> [email protected] >>>> >>> >>> >>> >>> -- >>> Henry Minsky >>> Software Architect >>> [email protected] >> > > -- Henry Minsky Software Architect [email protected]
