0

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?

squil
  • 121
  • 3
  • 7

1 Answers1

1

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
Brad Werth
  • 17,411
  • 10
  • 63
  • 88
Pesto
  • 23,810
  • 2
  • 71
  • 76