An object event such as a dragdrop onto an image can be assigned Functions using the IDE that results in the following stub code:
Code:
function tapOnDragDrop(Sender,Data,Point)
{
}
and an entry in main.xul that actually associates the image event with the function:
Code:
<image name="tap" onDragDrop="tapOnDragDrop"/>
Unfortunately, Xwidget does not allow you to associate a function to an object using code, it has to be done via the IDE. This sort of dynamic function assignment is not possible in Xwidget because the engine ignores any standard function definitions in code:
The following is a standard method of assigning a function in code using all variants of javascript.
Code:
lightTap.onMouseDown = function() {
.
.
.
}
In one of my programs I have a long bit of code duplicating twelve button images that could be concatenated to one function like this:
Code:
if (playListText.length > 0) {
for (var i in playListText) {
(function(i) {
playListText[i].onDragDrop = function (event) {
dropPosition = i;
catchFileDrop(event, null);
}
})(parseFloat(i)); //protect this value by setting it as value of a numeric variable in an immediately-called function
}
}
This code is perfectly valid javascript, it works in MS jscript upon which Xwidgets is based. It is just because xwidgets hijacks function definitions and insists they must be done manually through the IDE in order to be valid, that it no longer operates.
This code works in a browser and in the yahoo widget engine. Not in Xwidget.
The developer Tony should look at changing his engine to allow standard definitions in code. It can be done, it has been done. It is sad that Xwidgets is crippled in this way as it means standard javascript cannot be migrated to Xwidgets easily. It also results in kludgy code.
PS. Jim, add this please to the list of bugs.