user376
12-15-2011, 06:11 PM
I'm having an issue where a programmatic click event is not behaving the same way the cursor click event is. A cursor click returns the correct object from GetObject(). The programmatic click triggered by a USB device is returning undefined from GetObject(). How can this be resolved?
Edit: It appears that it does not recognize eval(document.getElementById(gButtonList[gButtonId])).onclick(); as an event. Why is this? How can I get it to recognize it?
Edit2: Resolved it myself. See green text below.
TestPage.htm:
<script language="JavaScript" src="../bin/USBHelperFile.js"></script>
<script language="JavaScript" type="text/JavaScript">
function BuildButtons()
{
for (var i = 0; i < testArray.length; i++)
{
// Create Div
var divNode = document.createElement('div');
divNode.id = 'div' + i;
divNode.onclick= ClickFunction;
etc...
}
}
function ClickFuntion(nodeButtonNum)
{
alert(GetObject());
Returns the index for a cursor click. Returns undefined for
the programmatic click triggered by the USB device
}
function GetObject()
{
var node = event.srcElement;
return node;
}
</script>
USBHelperFile.js:
This JS file works with a USB hardware device that can navigate
through divs and click them when they have focus.
function HelperFunction(keyCommand)
{
switch (keyCommand)
{
case: "click":
[b]//eval(document.getElementById(gButtonList[gButtonId])).onclick();
var target = eval(document.getElementById(gButtonList[gButtonId]));
target.fireEvent("onclick");
break;
}
}
Edit: It appears that it does not recognize eval(document.getElementById(gButtonList[gButtonId])).onclick(); as an event. Why is this? How can I get it to recognize it?
Edit2: Resolved it myself. See green text below.
TestPage.htm:
<script language="JavaScript" src="../bin/USBHelperFile.js"></script>
<script language="JavaScript" type="text/JavaScript">
function BuildButtons()
{
for (var i = 0; i < testArray.length; i++)
{
// Create Div
var divNode = document.createElement('div');
divNode.id = 'div' + i;
divNode.onclick= ClickFunction;
etc...
}
}
function ClickFuntion(nodeButtonNum)
{
alert(GetObject());
Returns the index for a cursor click. Returns undefined for
the programmatic click triggered by the USB device
}
function GetObject()
{
var node = event.srcElement;
return node;
}
</script>
USBHelperFile.js:
This JS file works with a USB hardware device that can navigate
through divs and click them when they have focus.
function HelperFunction(keyCommand)
{
switch (keyCommand)
{
case: "click":
[b]//eval(document.getElementById(gButtonList[gButtonId])).onclick();
var target = eval(document.getElementById(gButtonList[gButtonId]));
target.fireEvent("onclick");
break;
}
}