It seems reasonable but still this code does not work as it should (latest build on OSX)
Shoes.app do s=stack :width=>100 do para "Hello" end para s.width s.width=100 para s.width end K. On Sun, Dec 14, 2008 at 10:15 PM, _why <[email protected]> wrote: > On Sun, Dec 14, 2008 at 09:37:32PM +0100, [email protected] wrote: > > Shoes.app do > > stack :width => 100 do |s| > > para s.width > > end > > end > > > > But the stack doesn't yield itself inside the block (which I thought > would > > be logical :)) > > Most stacks don't know their own width until they get laid out for > the first time. During creating, the object is really only useful > for adding elements -- it doesn't have dimension. > > I mean imagine this: > > stack do |s| > para :width => s.width > end > > The width of the stack is based on the width of the para which is > based on the width of... the stack! > > So, the way we do it is: > > stack :width => 100 do > para :width => 1.0 # ... or "100%" > end > > You can also use local variables to compute the widths. Or you can > hook the `start` event, which will be run after the elements are > laid out for the first time (similar to window.onload.) > > _why >
