sending data to a WebAPI control

I have written several successful WebAPI controls for various things, but this current project is driving me nuts. I need to track some data for display over the top of an image in the mouseover event of an HTML canvas. Getting the mouseover event to call into my library code works fine, but I can’t seem to pass it any data. When new data is available for overlay I get an event in my Xojo class and a JSONItem that I want to just send to the browser to become a javascript data structure. There are no errors generated when I do this:

executeJavascript( “XojoCustom.myApp.myControl.myControlID = “ + myJSONItem.toString)

of course filling in the proper controlID and such.

in my HTML setup I am returning basically this, wrapped in the upper level DIV of course:

<canvas id="<>_canvas"
onmousemove="XojoCustom.MyApp.myControl.drawMouse( this, XojoCustom.myApp.myControl.<>)”>

again, replacing the controlid tags appropriately.
the drawMouse function in my library code is called but the second passed value is always undefined even when I know for certain that the first execute javascript has been called so there should be that javascript object available on the browser.

I feel like I’m completely missing the point of the name space and that something very obvious is happening like it’s already adding the XojoCustom so I’m adding it twice or something but I’ll be darned if I can see it.

In the past I’ve sent pre-made JSON data like that to the browser and accessed it through functions but I’ve never tried to just send it and access it directly and not through a library function like that.

Any suggestions for sending a control it’s rather large and complicated data structure in JSON would be greatly appreciated!
Thank you.

Ha :slight_smile: never mind :slight_smile: I had my javascript namespace set to “graphMouseover" and my other references using “mouseGraph" and of course when they didn’t match up. I had used the JavascriptNamespace constant to build the link where I was setting the data, so of course it didn’t match when I tried to accesss it via the other name :wink: Sigh… OK but we’re making progress now!

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.