31 lines
2.1 KiB
JSON
31 lines
2.1 KiB
JSON
{
|
|
"source": "JSON",
|
|
"data": "BLOCK",
|
|
"version": "0.0.1",
|
|
"type": "mouseposition",
|
|
"language": "javascript",
|
|
"extension": "webaudio",
|
|
"help": "Mouse Position",
|
|
"label": "Mouse Position",
|
|
"color": "50:50:50:150",
|
|
"group": "Input Device",
|
|
"codes": {
|
|
"function": "\n// ----------------- Mouse position ----------------------------\n// Detect if the browser is IE or not.\n// If it is not IE, we assume that the browser is NS.\nvar IE = document.all?true:false\n\n// If NS -- that is, !IE -- then set up for mouse capture\nif (!IE) document.captureEvents(Event.MOUSEMOVE)\n\n// Set-up to use getMouseXY function onMouseMove\ndocument.onmousemove = getMouseXY;\n\n// Temporary variables to hold mouse x-y pos.s\nvar tempX = 0\nvar tempY = 0\n\n// Variable to keep output ports\nvar x_ports = [];\nvar y_ports = [];\n\n// Main function to retrieve mouse x-y pos.s\n\nfunction getMouseXY(e) {\n if (IE) { // grab the x-y pos.s if browser is IE\n tempX = event.clientX + document.body.scrollLeft\n tempY = event.clientY + document.body.scrollTop\n } else { // grab the x-y pos.s if browser is NS\n tempX = e.pageX\n tempY = e.pageY\n }\n // catch possible negative values in NS4\n if (tempX < 0){tempX = 0}\n if (tempY < 0){tempY = 0}\n\n // X value\n for (var i = 0; i < x_ports.length ; i++)\n for (var j = 0; j < x_ports[i].length ; j++)\n x_ports[i][j](tempX);\n\n // Y value\n for (var i = 0; i < y_ports.length ; i++)\n for (var j = 0; j < y_ports[i].length ; j++)\n y_ports[i][j](tempY);\n return true\n}\n// ----------------- Mouse position ----------------------------\n",
|
|
"declaration": "\n// block_$id$ = Mouse\nvar $port[x]$ = [];\nvar $port[y]$ = [];\nx_ports.push($port[x]$);\ny_ports.push($port[y]$);\n"
|
|
},
|
|
"properties": [],
|
|
"ports": [
|
|
{
|
|
"type": "mosaicode_lib_javascript_webaudio.extensions.ports.float",
|
|
"conn_type": "Output",
|
|
"name": "x",
|
|
"label": "X"
|
|
},
|
|
{
|
|
"type": "mosaicode_lib_javascript_webaudio.extensions.ports.float",
|
|
"conn_type": "Output",
|
|
"name": "y",
|
|
"label": "Y"
|
|
}
|
|
]
|
|
} |