{"action":"created","issue":{"url":"https://api.github.com/repos/mit-cml/appinventor-sources/issues/347","labels_url":"https://api.github.com/repos/mit-cml/appinventor-sources/issues/347/labels{/name}","comments_url":"https://api.github.com/repos/mit-cml/appinventor-sources/issues/347/comments","events_url":"https://api.github.com/repos/mit-cml/appinventor-sources/issues/347/events","html_url":"https://github.com/mit-cml/appinventor-sources/pull/347","id":66037526,"number":347,"title":"Added multi/generic event handlers","user":{"login":"gitars","id":4552296,"avatar_url":"https://avatars.githubusercontent.com/u/4552296?v=3","gravatar_id":"","url":"https://api.github.com/users/gitars","html_url":"https://github.com/gitars","followers_url":"https://api.github.com/users/gitars/followers","following_url":"https://api.github.com/users/gitars/following{/other_user}","gists_url":"https://api.github.com/users/gitars/gists{/gist_id}","starred_url":"https://api.github.com/users/gitars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gitars/subscriptions","organizations_url":"https://api.github.com/users/gitars/orgs","repos_url":"https://api.github.com/users/gitars/repos","events_url":"https://api.github.com/users/gitars/events{/privacy}","received_events_url":"https://api.github.com/users/gitars/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":79,"created_at":"2015-04-03T00:09:40Z","updated_at":"2015-05-11T17:22:39Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/mit-cml/appinventor-sources/pulls/347","html_url":"https://github.com/mit-cml/appinventor-sources/pull/347","diff_url":"https://github.com/mit-cml/appinventor-sources/pull/347.diff","patch_url":"https://github.com/mit-cml/appinventor-sources/pull/347.patch"},"body":"Stemming off of stuff from here:\r\nhttps://github.com/mit-cml/appinventor-sources/pull/313\r\n\r\nThis is a solution to this problem that works like this (copied from other pull request thread):\r\nBasically, we still have the \"multi-generic\" event handler that returns a the component when it is called, but we register it as a normal event to one of the components on the screen, under a different name such as \"MultiGeneric-\" + EventName. Then, when a normal event occurs, we check all the components to see if any of them have a event closure for \"MultiGeneric-\" + EventName. Then, we simply add the component that triggered the event to the list of arguments and dispatch it.\r\n\r\nExample. A screen with three buttons, and this block. All of the blocks will have their text changed on click.\r\n\r\n![screen shot 2015-04-02 at 8 10 31 pm](https://cloud.githubusercontent.com/assets/4552296/6976195/20773086-d974-11e4-88eb-b9cd063e5b76.png)\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/mit-cml/appinventor-sources/issues/comments/100984112","html_url":"https://github.com/mit-cml/appinventor-sources/pull/347#issuecomment-100984112","issue_url":"https://api.github.com/repos/mit-cml/appinventor-sources/issues/347","id":100984112,"user":{"login":"gitars","id":4552296,"avatar_url":"https://avatars.githubusercontent.com/u/4552296?v=3","gravatar_id":"","url":"https://api.github.com/users/gitars","html_url":"https://github.com/gitars","followers_url":"https://api.github.com/users/gitars/followers","following_url":"https://api.github.com/users/gitars/following{/other_user}","gists_url":"https://api.github.com/users/gitars/gists{/gist_id}","starred_url":"https://api.github.com/users/gitars/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gitars/subscriptions","organizations_url":"https://api.github.com/users/gitars/orgs","repos_url":"https://api.github.com/users/gitars/repos","events_url":"https://api.github.com/users/gitars/events{/privacy}","received_events_url":"https://api.github.com/users/gitars/received_events","type":"User","site_admin":false},"created_at":"2015-05-11T17:22:39Z","updated_at":"2015-05-11T17:22:39Z","body":"@mark-friedman \r\nHey, so I'm having trouble with types and I was wondering if you could clear up something for me. So if you want to set a button's text, if you do it in this way, you get the following Yail.\r\n\r\n![screen shot 2015-05-11 at 1 10 09 pm](https://cloud.githubusercontent.com/assets/4552296/7570617/75497018-f7df-11e4-96c6-3a44fce9de35.png)\r\n\r\n(set-and-coerce-property-and-check! (get-component Button1) 'Button 'Text \"text\" 'text)\r\n\r\n\r\nIf you do it, this way, you get this Yail (for each button in the list):\r\n\r\n![screen shot 2015-05-11 at 1 14 25 pm](https://cloud.githubusercontent.com/assets/4552296/7570632/9036e43c-f7df-11e4-9185-616e75470d6c.png)\r\n\r\n(set-and-coerce-property-and-check! (lexical-value $item) 'Button 'Text \"text\" 'text)\r\n\r\n\r\nSo it must be the case that (lexical-value $item) has the same type as (get-component Button1). First question is, what is the actual type?\r\n\r\nNext, when defining generic events, the Yail looks something like this normally:\r\n\r\n(define-generic-event Button1 Click()(set-this-form) .... )\r\n\r\nHowever, if we are setting generic events while iterating through a list (so like the example @halatmit provided: https://cloud.githubusercontent.com/assets/789431/7442148/58a9aa0e-f0d2-11e4-9bb3-e1efa8145cd4.png), we have to generate Yail that evaluates to the same type, but I'm not really sure what that type is/how to. At first, I thought it would be (lexical-value $item), but that type seems to match up with (get-component Button1), not just \"Button1\", as shown above. Do you have any ideas about this?\r\n\r\nAlso, my next question is, sometimes I notice that an apostrophe right before a variable. What does that do? For example, in define-event, \"(add-to-events 'component-name 'event-name)\""}}