> Well, width gets called on whatever self is if you don't call it on an
> object explicitly. Since self is always the Shoes::App in shoes, simply
> calling width() gives you the width of the shoes window.
That explanation helps, thanks.
> Shoes.app :width => 1200 do
> @s = stack :width => 300 do
> para "value of self inside the stack: #{self}"
> para "class of @s inside the stack: #[email protected]}"
> end
> para "class of @s outside the stack: #[email protected]}"
> para "Width outside the stack: #{width}"
> para "Width inside the stack: #[email protected]}"
> end
I did try something similar with:
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 :))
> The value of @s does not get "set" until the stack is closed in this case
> and so @s.class evaluates first to nil and then later to Shoes::Stack once
> the stack has been closed. But, @s.width gives me 0 once outside the
> stack.
> Also, by way of the example in the manual under "Elements: Common width()
> >>
> a number", I am led to believe that one should be able to reference @s
> within the block. Is this possibly a bug with my version (REVISION =
> 1057)?
>
> Cheers
Thanks,
>
>
> On Sun, Dec 14, 2008 at 7:29 AM, <[email protected]> wrote:
>
>> Hi all,
>>
>> I am a bit puzzled about the behaviour of width/height inside a stack.
>> The
>> manual says:
>> width() ยป a number
>> The horizontal size of the slot in pixels.
>>
>> Where I understand the slot to be the current stack. The following
>> trivial
>> example shows that this is not the case:
>> Shoes.app do
>> stack :width => 100 do
>> para "Width inside the stack: #{width}"
>> end
>> para "Width outside the stack: #{width}"
>> end
>>
>> Is this expected behaviour?
>>
>> I know I could use style[:width], but then I'd have to handle the
>> special
>> cases such as width is a percentage of a float. Besides I would find the
>> other behaviour more intuitive and helpfull :)
>>
>> I am using shoes2 on linux.
>>
>> Cheers, Edwin
>>
>>
>