This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Matt Wujek
Posted Jan 14 - Read on Facebook

Quick question:

I need to select multiple items from my Sketch file. How do you do this? This was what I tried and it didn't work :(

allButtons = [btn1, btn2, btn3, btn4]

allButtons.style = {

}

allButtons.states.add({

})

allButtons[0].on Events.Click, ->

8 Comments

Ryan Gonzalez

Here you go:

Matt Wujek

Perfect, thanks Ryan!

Ryan Gonzalez

No problem!

Matt Wujek

Ryan, just FYI, I tried the top answer and it didn't handle the click events correctly. It only applied the event to the last element in the array. However, the map solution worked perfectly. Thanks again!

Ryan Gonzalez

ah right, that’s a quirk with Javascript’s function based scoping: http://stackoverflow.com/questions/750486/javascript-closure-inside-loops-simple-practical-example

Ryan Gonzalez

Rewriting the top approach to this should fix the issue (by capturing the `button` var in a new function scope):

Matt Wujek

Great, thanks for taking time to look at this!

Koen Bok

Note that you also get the layer that got the event in an event handler:

layer.on Events.Click, (event, layer) ->
print layer

Read the entire post on Facebook