On Jul 26, 2008, at 11:27 AM, Edward Heil wrote:


This code actually just crashes for me on OS X though -- crashes during the click handler! I've been fiddling around trying to figure out why it crashes with no luck so far.

It's the "alert." Change it to "debug" and it doesn't crash for me. Hm. That's an interesting bug. I wonder what circumstances cause an "alert" to crash Shoes on OS X?

OK, so this is the *minimal* change to what you had to make it work -- I initialize a variable inside the block to make it block-scoped, with the name "block_scoped_i" :) I'd suggest just going to an each_with_index though.

Shoes.app :width => 840, :height => 700, :title => "Test" do

 def list_view(ary)
   i = -1
   ary.map {|e|
     i = i + 1
     block_scoped_i = i
     flow do
       background (i % 2 == 0 ? lightblue : white)
       para e, :size => 8
       click do
         debug block_scoped_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


Reply via email to