how to pass the right index to the method?
for key, index in sketch.keypad.subLayers key.onTap -> addAmount(index)
Now is always the last digit of iteration for each sublayers (
In this case, the event will happen after the loop has finished, so the index will always be the last index. You'll need to store the index for each layer, so that when it's clicked it'll trigger the right amount. To do this write "key.amount = index" before the event inside the loop. Then on the tap event, write "addAmount(@.amount)", and that'll give you the right amount.