tags:

views:

54

answers:

1

I've got this piece of Shoes app:

flow :top => 10, :left => 10 do
  flow :width => 0.3 do 
    para @board.deck.card
    click do
      if @board.source_pile
        @board.source_pile = nil
        @deck_border.hide
      else
        @board.source_pile = @board.deck
        @deck_border = border yellow, :strokewidth => 2
      end
    end
  end
end

I would like to apply border only to the second flow, but for some reason the border appears around the whole application. What am I missing?

A: 

Shoes has tricky blocks. In a nutshell, in blocks, self typically refers to the application. To counter this, we'll have to create a variable to hold the flow we want to border:

flow :top => 10, :left => 10 do
  inner = flow :width => 0.3 do 
    para @board.deck.card
    click do
      if @board.source_pile
        @board.source_pile = nil
        @deck_border.hide
      else
        @board.source_pile = @board.deck
        @deck_border = inner.border yellow, :strokewidth => 2
      end
    end
  end
end
Pesto
ahhh nice :D I tried to do flow do |inner|but that didn't work. Thanks!
squil