So how do I give each flow its own click? (For that matter, am I doing
this the right way in the first place? What I need is a basic
one-column list view each of whose cells can have a different height
and background colour, and a click handler that's aware of which cell
was clicked. If there's a simpler way to achieve that than the code
below, I'm open to suggestions.)
martin
On Fri, Jul 25, 2008 at 3:19 PM, Ernest Prabhakar
<[EMAIL PROTECTED]> wrote:
> Hi Martin,
>
> Click is a handler, I think, so the block it is passed gets executed
> asynchronously. Also, that means the last one defined is the only one that
> matters.
>
> -- Ernie P.
>
> On Jul 25, 2008, at 3:12 PM, Martin DeMello wrote:
>
>> What's going on in the below code? I expected each number to capture
>> the current value of i in its click callback, but every click says
>> "10"
>>
>> martin
>>
>> Shoes.app :width => 840, :height => 700, :title => "Test" do
>>
>> def list_view(ary)
>> i = -1
>> ary.map {|e|
>> i = i + 1
>> flow do
>> background (i % 2 == 0 ? lightblue : white)
>> para e, :size => 8
>> click do
>> alert i
>> end
>> end
>> }
>> end
>>
>> background white
>>
>> stack :width => 280, :margin_top => 20, :margin_left => 10, :height =>
>> 600 do
>> @listview = stack :width => 275, :margin => 10, :height => 580,
>> :scroll => true do
>> background white
>> append do
>> list_view (0..10).to_a
>> end
>> end
>> end
>> end
>
>