43 lines
2.0 KiB
JSON
43 lines
2.0 KiB
JSON
{
|
|
"source": "JSON",
|
|
"data": "BLOCK",
|
|
"version": "0.0.1",
|
|
"type": "javascript.input devices.mouseclick",
|
|
"language": "javascript",
|
|
"extension": "webaudio",
|
|
"help": "Mouse Click",
|
|
"label": "Mouse Click",
|
|
"color": "#4283FA",
|
|
"group": "Input Device",
|
|
"codes": [
|
|
{
|
|
"name": "function",
|
|
"code": "\n// ----------------- Mouse click ----------------------------\n// Variable to keep output ports\nvar x_click_ports = [];\nvar y_click_ports = [];\nvar button_click_ports = [];\n\ndocument.onmousedown = getMouseClick;\nfunction getMouseClick(event) {\n // X value\n for (var i = 0; i < x_click_ports.length ; i++)\n for (var j = 0; j < x_click_ports[i].length ; j++)\n x_click_ports[i][j](event.x);\n\n // Y value\n for (var i = 0; i < y_click_ports.length ; i++)\n for (var j = 0; j < y_click_ports[i].length ; j++)\n y_click_ports[i][j](event.y);\n\n // Button value\n for (var i = 0; i < button_click_ports.length ; i++)\n for (var j = 0; j < button_click_ports[i].length ; j++)\n button_click_ports[i][j](event.button);\n\n return true\n}\n// ----------------- Mouse position ----------------------------\n\n"
|
|
},
|
|
{
|
|
"name": "declaration",
|
|
"code": "\n// block_$id$ = Mouse\nvar $port[x]$ = [];\nvar $port[y]$ = [];\nvar $port[button]$ = [];\nx_click_ports.push($port[x]$);\ny_click_ports.push($port[y]$);\nbutton_click_ports.push($port[button]$);\n"
|
|
}
|
|
],
|
|
"properties": [],
|
|
"ports": [
|
|
{
|
|
"conn_type": "output",
|
|
"name": "x",
|
|
"label": "X",
|
|
"type": "javascript.float"
|
|
},
|
|
{
|
|
"conn_type": "output",
|
|
"name": "y",
|
|
"label": "Y",
|
|
"type": "javascript.float"
|
|
},
|
|
{
|
|
"conn_type": "output",
|
|
"name": "button",
|
|
"label": "Button",
|
|
"type": "javascript.float"
|
|
}
|
|
]
|
|
} |