{"action":"created","comment":{"url":"https://api.github.com/repos/LLK/scratch-gui/pulls/comments/216155194","pull_request_review_id":153579482,"id":216155194,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNjE1NTE5NA==","diff_hunk":"@@ -110,6 +110,75 @@ export default function (vm) {\n         return [[myself, '_myself_']].concat(spriteMenu());\n     };\n \n+    const variablePropertyMenu = function (thisValue) {\n+        // Fill the output array with sprite properties by default. This will be changed to stage properties if the\n+        // stage is selected.\n+        const xPosition = ScratchBlocks.ScratchMsgs.translate('SENSING_OF_XPOSITION', 'x position');\n+        const yPosition = ScratchBlocks.ScratchMsgs.translate('SENSING_OF_YPOSITION', 'y position');\n+        const direction = ScratchBlocks.ScratchMsgs.translate('SENSING_OF_DIRECTION', 'direction');\n+        const costumeNumber = ScratchBlocks.ScratchMsgs.translate('SENSING_OF_COSTUMENUMBER', 'costume #');\n+        const costumeName = ScratchBlocks.ScratchMsgs.translate('SENSING_OF_COSTUMENAME', 'costume name');\n+        const size = ScratchBlocks.ScratchMsgs.translate('SENSING_OF_SIZE', 'size');\n+        const volume = ScratchBlocks.ScratchMsgs.translate('SENSING_OF_VOLUME', 'volume');\n+        let output = [\n+            [xPosition, 'x position'],\n+            [yPosition, 'y position'],\n+            [direction, 'direction'],\n+            [costumeNumber, 'costume #'],\n+            [costumeName, 'costume name'],\n+            [size, 'size'],\n+            [volume, 'volume']\n+        ];\n+\n+        const sourceBlock = thisValue.sourceBlock_; // This is the <shadow>.\n+        const ofBlock = sourceBlock && sourceBlock.parentBlock_; // This is the \"of\" block.\n+        if (ofBlock) {\n+            let block;\n+            let blocks;\n+            if (vm.editingTarget) {\n+                blocks = vm.editingTarget.blocks;\n+                block = blocks.getBlock(ofBlock.id);\n+            }\n+            if (!block) {\n+                // The block may be in the flyout.\n+                blocks = vm.runtime.flyoutBlocks;\n+                block = blocks.getBlock(ofBlock.id);\n+            }\n+            if (block) {\n+                // Get the name of the sprite which is selected. This is based on the OBJECT dropdown's selected value,\n+                // which may be different from the value returned by a block placed within that input, if present.\n+                // TODO: Variables should probably not be fetched at all if the OBJECT dropdown contains a block.\n+                const objectInput = blocks.getInputs(block).OBJECT;\n+                const objectInputBlock = blocks.getBlock(objectInput.block);\n+                const valueField = blocks.getFields(objectInputBlock).OBJECT;\n+                const objectName = valueField.value;\n+\n+                // Only return options for local variables of sprites, since the stage's local variables are really\n+                // the project's global variables.\n+                if (objectName === '_stage_') {\n+                    // If the stage is the selected object (of the dropdown), only return properties relevant to it.\n+                    const backdropNumber = ScratchBlocks.ScratchMsgs.translate(\n+                        'SENSING_OF_BACKDROPNUMBER', 'backdrop #');\n+                    const backdropName = ScratchBlocks.ScratchMsgs.translate(\n+                        'SENSING_OF_BACKDROPNAME', 'backdrop name');\n+                    output = [\n+                        [backdropNumber, 'backdrop #'],\n+                        [backdropName, 'backdrop name'],\n+                        [volume, 'volume']\n+                    ];","path":"src/lib/blocks.js","position":68,"original_position":68,"commit_id":"f883344c6bcbc58fb7017eee5de20277fb382ae7","original_commit_id":"ebb8f951a735dcad040018d927a184a38c637714","user":{"login":"towerofnix","id":9948030,"node_id":"MDQ6VXNlcjk5NDgwMzA=","avatar_url":"https://avatars3.githubusercontent.com/u/9948030?v=4","gravatar_id":"","url":"https://api.github.com/users/towerofnix","html_url":"https://github.com/towerofnix","followers_url":"https://api.github.com/users/towerofnix/followers","following_url":"https://api.github.com/users/towerofnix/following{/other_user}","gists_url":"https://api.github.com/users/towerofnix/gists{/gist_id}","starred_url":"https://api.github.com/users/towerofnix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/towerofnix/subscriptions","organizations_url":"https://api.github.com/users/towerofnix/orgs","repos_url":"https://api.github.com/users/towerofnix/repos","events_url":"https://api.github.com/users/towerofnix/events{/privacy}","received_events_url":"https://api.github.com/users/towerofnix/received_events","type":"User","site_admin":false},"body":"This is irrelevant now since we return the stage's local variables (the project's global variables).","created_at":"2018-09-09T11:41:52Z","updated_at":"2018-09-09T11:41:52Z","html_url":"https://github.com/LLK/scratch-gui/pull/3102#discussion_r216155194","pull_request_url":"https://api.github.com/repos/LLK/scratch-gui/pulls/3102","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/LLK/scratch-gui/pulls/comments/216155194"},"html":{"href":"https://github.com/LLK/scratch-gui/pull/3102#discussion_r216155194"},"pull_request":{"href":"https://api.github.com/repos/LLK/scratch-gui/pulls/3102"}},"in_reply_to_id":216145426},"pull_request":{"url":"https://api.github.com/repos/LLK/scratch-gui/pulls/3102","id":214123795,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE0MTIzNzk1","html_url":"https://github.com/LLK/scratch-gui/pull/3102","diff_url":"https://github.com/LLK/scratch-gui/pull/3102.diff","patch_url":"https://github.com/LLK/scratch-gui/pull/3102.patch","issue_url":"https://api.github.com/repos/LLK/scratch-gui/issues/3102","number":3102,"state":"open","locked":false,"title":"Add variables to dropdown menu, and more goodies","user":{"login":"towerofnix","id":9948030,"node_id":"MDQ6VXNlcjk5NDgwMzA=","avatar_url":"https://avatars3.githubusercontent.com/u/9948030?v=4","gravatar_id":"","url":"https://api.github.com/users/towerofnix","html_url":"https://github.com/towerofnix","followers_url":"https://api.github.com/users/towerofnix/followers","following_url":"https://api.github.com/users/towerofnix/following{/other_user}","gists_url":"https://api.github.com/users/towerofnix/gists{/gist_id}","starred_url":"https://api.github.com/users/towerofnix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/towerofnix/subscriptions","organizations_url":"https://api.github.com/users/towerofnix/orgs","repos_url":"https://api.github.com/users/towerofnix/repos","events_url":"https://api.github.com/users/towerofnix/events{/privacy}","received_events_url":"https://api.github.com/users/towerofnix/received_events","type":"User","site_admin":false},"body":"### Resolves\r\n\r\nResolves LLK/scratch-vm#1425: \"For this sprite only\" (local) variables are now shown in the dropdown.\r\n\r\nResolves LLK/scratch-blocks#1418: This is unintentional (a side-effect of reusing the basic code for the object dropdown), but the property dropdown now accepts blocks.\r\n\r\nFixes backdrop options (backdrop name, backdrop #) from being shown in sprite dropdowns, and vice versa (x position, etc, in stage dropdown). I couldn't spot an issue for this one.\r\n\r\n**Depends on LLK/scratch-blocks#1712.** Merge this one after that one!\r\n\r\n### Proposed Changes\r\n\r\nThis PR reworks how the `PROPERTY` dropdown of the \"(property) of (object)\" sensing reporter block works internally, allowing for the changes listed above.\r\n\r\nNote that the property dropdown now accepts blocks. That's not intentional - it's just that I reused most of the code for the object dropdown. I'm not sure how to make it a \"square\" dropdown (i.e. one which does not accept blocks). In my opinion, letting it accept blocks is a good thing anyways, since it allows and encourages dynamically accessing variables (or even ordinary attributes, like \"x position\" and \"direction\"). The argument against it is that an unfamiliar user might try placing a block such as \"volume\" into that dropdown, and then be confused as to why it always returns 0. But I think that any such user would quickly figure out the error they made; I think the functional benefit greatly outweighs the minor potential difficulty.\r\n\r\nThat said, I'm okay with making the input not accept blocks, if it'd be preferred to merge this sooner and keep discussion about that topic in its particular issue.\r\n\r\nThere are some comments I have on specific parts of the code. I'll leave those in a review of the PR.\r\n\r\n### Reason for Changes\r\n\r\nThese are nearly all bug-fixes / enhancements which make the Scratch 3.0 editor match 2.0.\r\n\r\n### Test Coverage\r\n\r\nI haven't added any new unit tests, but this has been tested manually:\r\n\r\n* The \"of\" block can be dragged out of the flyout with default or changed dropdowns without any errors.\r\n* With the stage selected, the dropdown includes (translated) options for properties relevant to the stage, and no variables.\r\n* With a sprite selected, the dropdown includes (translated) options for properties relevant to sprites, and all variables which are local to that sprite, and no global variables.","created_at":"2018-09-09T02:15:26Z","updated_at":"2018-09-09T11:41:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"45ea4c74d7287c002b0cf522e50d5726222b6bfb","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/LLK/scratch-gui/pulls/3102/commits","review_comments_url":"https://api.github.com/repos/LLK/scratch-gui/pulls/3102/comments","review_comment_url":"https://api.github.com/repos/LLK/scratch-gui/pulls/comments{/number}","comments_url":"https://api.github.com/repos/LLK/scratch-gui/issues/3102/comments","statuses_url":"https://api.github.com/repos/LLK/scratch-gui/statuses/f883344c6bcbc58fb7017eee5de20277fb382ae7","head":{"label":"towerofnix:better-sensing-dropdown-gui","ref":"better-sensing-dropdown-gui","sha":"f883344c6bcbc58fb7017eee5de20277fb382ae7","user":{"login":"towerofnix","id":9948030,"node_id":"MDQ6VXNlcjk5NDgwMzA=","avatar_url":"https://avatars3.githubusercontent.com/u/9948030?v=4","gravatar_id":"","url":"https://api.github.com/users/towerofnix","html_url":"https://github.com/towerofnix","followers_url":"https://api.github.com/users/towerofnix/followers","following_url":"https://api.github.com/users/towerofnix/following{/other_user}","gists_url":"https://api.github.com/users/towerofnix/gists{/gist_id}","starred_url":"https://api.github.com/users/towerofnix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/towerofnix/subscriptions","organizations_url":"https://api.github.com/users/towerofnix/orgs","repos_url":"https://api.github.com/users/towerofnix/repos","events_url":"https://api.github.com/users/towerofnix/events{/privacy}","received_events_url":"https://api.github.com/users/towerofnix/received_events","type":"User","site_admin":false},"repo":{"id":91981056,"node_id":"MDEwOlJlcG9zaXRvcnk5MTk4MTA1Ng==","name":"scratch-gui","full_name":"towerofnix/scratch-gui","owner":{"login":"towerofnix","id":9948030,"node_id":"MDQ6VXNlcjk5NDgwMzA=","avatar_url":"https://avatars3.githubusercontent.com/u/9948030?v=4","gravatar_id":"","url":"https://api.github.com/users/towerofnix","html_url":"https://github.com/towerofnix","followers_url":"https://api.github.com/users/towerofnix/followers","following_url":"https://api.github.com/users/towerofnix/following{/other_user}","gists_url":"https://api.github.com/users/towerofnix/gists{/gist_id}","starred_url":"https://api.github.com/users/towerofnix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/towerofnix/subscriptions","organizations_url":"https://api.github.com/users/towerofnix/orgs","repos_url":"https://api.github.com/users/towerofnix/repos","events_url":"https://api.github.com/users/towerofnix/events{/privacy}","received_events_url":"https://api.github.com/users/towerofnix/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/towerofnix/scratch-gui","description":"Graphical User Interface for creating and running Scratch 3.0 projects.","fork":true,"url":"https://api.github.com/repos/towerofnix/scratch-gui","forks_url":"https://api.github.com/repos/towerofnix/scratch-gui/forks","keys_url":"https://api.github.com/repos/towerofnix/scratch-gui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/towerofnix/scratch-gui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/towerofnix/scratch-gui/teams","hooks_url":"https://api.github.com/repos/towerofnix/scratch-gui/hooks","issue_events_url":"https://api.github.com/repos/towerofnix/scratch-gui/issues/events{/number}","events_url":"https://api.github.com/repos/towerofnix/scratch-gui/events","assignees_url":"https://api.github.com/repos/towerofnix/scratch-gui/assignees{/user}","branches_url":"https://api.github.com/repos/towerofnix/scratch-gui/branches{/branch}","tags_url":"https://api.github.com/repos/towerofnix/scratch-gui/tags","blobs_url":"https://api.github.com/repos/towerofnix/scratch-gui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/towerofnix/scratch-gui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/towerofnix/scratch-gui/git/refs{/sha}","trees_url":"https://api.github.com/repos/towerofnix/scratch-gui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/towerofnix/scratch-gui/statuses/{sha}","languages_url":"https://api.github.com/repos/towerofnix/scratch-gui/languages","stargazers_url":"https://api.github.com/repos/towerofnix/scratch-gui/stargazers","contributors_url":"https://api.github.com/repos/towerofnix/scratch-gui/contributors","subscribers_url":"https://api.github.com/repos/towerofnix/scratch-gui/subscribers","subscription_url":"https://api.github.com/repos/towerofnix/scratch-gui/subscription","commits_url":"https://api.github.com/repos/towerofnix/scratch-gui/commits{/sha}","git_commits_url":"https://api.github.com/repos/towerofnix/scratch-gui/git/commits{/sha}","comments_url":"https://api.github.com/repos/towerofnix/scratch-gui/comments{/number}","issue_comment_url":"https://api.github.com/repos/towerofnix/scratch-gui/issues/comments{/number}","contents_url":"https://api.github.com/repos/towerofnix/scratch-gui/contents/{+path}","compare_url":"https://api.github.com/repos/towerofnix/scratch-gui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/towerofnix/scratch-gui/merges","archive_url":"https://api.github.com/repos/towerofnix/scratch-gui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/towerofnix/scratch-gui/downloads","issues_url":"https://api.github.com/repos/towerofnix/scratch-gui/issues{/number}","pulls_url":"https://api.github.com/repos/towerofnix/scratch-gui/pulls{/number}","milestones_url":"https://api.github.com/repos/towerofnix/scratch-gui/milestones{/number}","notifications_url":"https://api.github.com/repos/towerofnix/scratch-gui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/towerofnix/scratch-gui/labels{/name}","releases_url":"https://api.github.com/repos/towerofnix/scratch-gui/releases{/id}","deployments_url":"https://api.github.com/repos/towerofnix/scratch-gui/deployments","created_at":"2017-05-21T19:10:41Z","updated_at":"2018-03-16T14:33:15Z","pushed_at":"2018-09-09T11:40:10Z","git_url":"git://github.com/towerofnix/scratch-gui.git","ssh_url":"git@github.com:towerofnix/scratch-gui.git","clone_url":"https://github.com/towerofnix/scratch-gui.git","svn_url":"https://github.com/towerofnix/scratch-gui","homepage":"http://llk.github.io/scratch-gui","size":47578,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"LLK:develop","ref":"develop","sha":"d83dfc3bd8275ce8c87db29bd391ce57ddec4825","user":{"login":"LLK","id":3420800,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM0MjA4MDA=","avatar_url":"https://avatars1.githubusercontent.com/u/3420800?v=4","gravatar_id":"","url":"https://api.github.com/users/LLK","html_url":"https://github.com/LLK","followers_url":"https://api.github.com/users/LLK/followers","following_url":"https://api.github.com/users/LLK/following{/other_user}","gists_url":"https://api.github.com/users/LLK/gists{/gist_id}","starred_url":"https://api.github.com/users/LLK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LLK/subscriptions","organizations_url":"https://api.github.com/users/LLK/orgs","repos_url":"https://api.github.com/users/LLK/repos","events_url":"https://api.github.com/users/LLK/events{/privacy}","received_events_url":"https://api.github.com/users/LLK/received_events","type":"Organization","site_admin":false},"repo":{"id":68243930,"node_id":"MDEwOlJlcG9zaXRvcnk2ODI0MzkzMA==","name":"scratch-gui","full_name":"LLK/scratch-gui","owner":{"login":"LLK","id":3420800,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM0MjA4MDA=","avatar_url":"https://avatars1.githubusercontent.com/u/3420800?v=4","gravatar_id":"","url":"https://api.github.com/users/LLK","html_url":"https://github.com/LLK","followers_url":"https://api.github.com/users/LLK/followers","following_url":"https://api.github.com/users/LLK/following{/other_user}","gists_url":"https://api.github.com/users/LLK/gists{/gist_id}","starred_url":"https://api.github.com/users/LLK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LLK/subscriptions","organizations_url":"https://api.github.com/users/LLK/orgs","repos_url":"https://api.github.com/users/LLK/repos","events_url":"https://api.github.com/users/LLK/events{/privacy}","received_events_url":"https://api.github.com/users/LLK/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/LLK/scratch-gui","description":"Graphical User Interface for creating and running Scratch 3.0 projects.","fork":false,"url":"https://api.github.com/repos/LLK/scratch-gui","forks_url":"https://api.github.com/repos/LLK/scratch-gui/forks","keys_url":"https://api.github.com/repos/LLK/scratch-gui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LLK/scratch-gui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LLK/scratch-gui/teams","hooks_url":"https://api.github.com/repos/LLK/scratch-gui/hooks","issue_events_url":"https://api.github.com/repos/LLK/scratch-gui/issues/events{/number}","events_url":"https://api.github.com/repos/LLK/scratch-gui/events","assignees_url":"https://api.github.com/repos/LLK/scratch-gui/assignees{/user}","branches_url":"https://api.github.com/repos/LLK/scratch-gui/branches{/branch}","tags_url":"https://api.github.com/repos/LLK/scratch-gui/tags","blobs_url":"https://api.github.com/repos/LLK/scratch-gui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LLK/scratch-gui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LLK/scratch-gui/git/refs{/sha}","trees_url":"https://api.github.com/repos/LLK/scratch-gui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LLK/scratch-gui/statuses/{sha}","languages_url":"https://api.github.com/repos/LLK/scratch-gui/languages","stargazers_url":"https://api.github.com/repos/LLK/scratch-gui/stargazers","contributors_url":"https://api.github.com/repos/LLK/scratch-gui/contributors","subscribers_url":"https://api.github.com/repos/LLK/scratch-gui/subscribers","subscription_url":"https://api.github.com/repos/LLK/scratch-gui/subscription","commits_url":"https://api.github.com/repos/LLK/scratch-gui/commits{/sha}","git_commits_url":"https://api.github.com/repos/LLK/scratch-gui/git/commits{/sha}","comments_url":"https://api.github.com/repos/LLK/scratch-gui/comments{/number}","issue_comment_url":"https://api.github.com/repos/LLK/scratch-gui/issues/comments{/number}","contents_url":"https://api.github.com/repos/LLK/scratch-gui/contents/{+path}","compare_url":"https://api.github.com/repos/LLK/scratch-gui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LLK/scratch-gui/merges","archive_url":"https://api.github.com/repos/LLK/scratch-gui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LLK/scratch-gui/downloads","issues_url":"https://api.github.com/repos/LLK/scratch-gui/issues{/number}","pulls_url":"https://api.github.com/repos/LLK/scratch-gui/pulls{/number}","milestones_url":"https://api.github.com/repos/LLK/scratch-gui/milestones{/number}","notifications_url":"https://api.github.com/repos/LLK/scratch-gui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LLK/scratch-gui/labels{/name}","releases_url":"https://api.github.com/repos/LLK/scratch-gui/releases{/id}","deployments_url":"https://api.github.com/repos/LLK/scratch-gui/deployments","created_at":"2016-09-14T21:14:10Z","updated_at":"2018-09-08T15:52:45Z","pushed_at":"2018-09-09T11:40:12Z","git_url":"git://github.com/LLK/scratch-gui.git","ssh_url":"git@github.com:LLK/scratch-gui.git","clone_url":"https://github.com/LLK/scratch-gui.git","svn_url":"https://github.com/LLK/scratch-gui","homepage":"https://preview.scratch.mit.edu","size":439641,"stargazers_count":757,"watchers_count":757,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":540,"mirror_url":null,"archived":false,"open_issues_count":524,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":540,"open_issues":524,"watchers":757,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/LLK/scratch-gui/pulls/3102"},"html":{"href":"https://github.com/LLK/scratch-gui/pull/3102"},"issue":{"href":"https://api.github.com/repos/LLK/scratch-gui/issues/3102"},"comments":{"href":"https://api.github.com/repos/LLK/scratch-gui/issues/3102/comments"},"review_comments":{"href":"https://api.github.com/repos/LLK/scratch-gui/pulls/3102/comments"},"review_comment":{"href":"https://api.github.com/repos/LLK/scratch-gui/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/LLK/scratch-gui/pulls/3102/commits"},"statuses":{"href":"https://api.github.com/repos/LLK/scratch-gui/statuses/f883344c6bcbc58fb7017eee5de20277fb382ae7"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"towerofnix"}}