From: Raymond I. <xw...@ya...> - 2003-08-13 23:15:46
|
Hi, The getContentWidth() function can only return the correct value after the page has been loaded or after the object (DynLayer) has been created. -- Raymond Irving --- ml...@id... wrote: > > I have the following test case. > > What I want to do is determine the size of a > template object after I > fill in the field values. This needs to work, after > the template has > been added to the document. > > It doesn't appear to for some reason. > > > Relevant code: the width value never changes even > after I add the > child field > > var body = 'I am a simply layer, what is my size, > oldWidth is my size before we fill in a template > field, newWidth is the size afterwards. {@field}'; > var sizeTemplate = new Template(body); > dynapi.document.addChild(sizeTemplate); > > var oldWidth = sizeTemplate.getWidth(); > var oldContentWidth = > sizeTemplate.getContentWidth(); > > sizeTemplate.addChild(new > DynLayer('hello'),'field'); > sizeTemplate.setLocation( 0, 100 ); > sizeTemplate.setBgColor( '#FFFFFF' ); > > var newWidth = sizeTemplate.getWidth(); > var newContentWidth = > sizeTemplate.getContentWidth(); > > var wLayer; > if( oldWidth == newWidth ) { > wLayer = new DynLayer( 'oldWidth == newWidth = ' + > sizeTemplate.getWidth() ); > } else { > wLayer = new DynLayer( 'oldWidth(' + oldWidth + ') > != newWidth(' + > sizeTemplate.getWidth() + ')' ); > } > wLayer.setLocation( 0, 200 ); > dynapi.document.addChild( wLayer ); > wLayer.setBgColor( '#FFFFFF' ); > > > > var cLayer > if( oldContentWidth == newContentWidth ) { > cLayer = new DynLayer( 'oldContentWidth == > newContentWidth = ' + sizeTemplate.getContentWidth() > ); > } else { > cwLayer = new DynLayer( 'oldContentWidth(' + > oldContentWidth + ') != newContentWidth(' + > sizeTemplate.getContentWidth() + ')' ); > } > cLayer.setLocation( 0, 300 ); > dynapi.document.addChild( cLayer ); > cLayer.setBgColor( '#FFFFFF' ); > > > #text/html; name="mysize.html" [Test file] > /tmp/mysize.html > > > ------------------------------------------------------- > This SF.Net email sponsored by: Free pre-built > ASP.NET sites including > Data Reports, E-commerce, Portals, and Forums are > available now. > Download today and enter to win an XBOX or Visual > Studio .NET. > http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 > _______________________________________________ > Dynapi-Help mailing list > Dyn...@li... > https://lists.sourceforge.net/lists/listinfo/dynapi-help __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com |