Ive got one very successful WebSDK control under my belt now. Its just an html canvas and I put a draw method into a local library. When I need to reload it I can send it all the information I need with a single call to the library method that also gets a reference to the control. There are no local variables or other things that it needs to store on a canvas by canvas basis so the fact that the screen can hold many of them doesnt matter, the control itself is very simple.
For my next project I need to build a more complicated control that will store some min/max values and do some math as you interact with it. Ive got it working as a standalone bit of javascript and html code and Im ready to start converting to a webSDK control. My problem is that the values are currently stored as globals within that script and all my methods access them. Im having trouble wrapping my head around how I can encapsulate those globals into the actual control object since each control object will have different values to build their displays from.
If I include a script inside the HTML code and pass it in the SetupHTML handler will that somehow become available on a control by control basis? its just my relative inexperience with javascript that is causing me this pain I can get the canvas reference inside the library drawing code by doing something like: (thisParent is passed into the library call by my event from Xojo)
var thisCanvas = thisParent.children[0];
as is documented in the SDK. but then I need to be able to get more information about it like:
var maxValue = thisParent.maxValue
var minValue = thisParent.minValue
how can I put those into the control so I can get them to the library drawing code when it needs them? These things really do need to be stored on the browser as Ill be redrawing in response to mouse/touch drags which you cant do by sending events back and forth to the server. The only event Ill be sending back will be the final value when youre done working with the control.
Any philosophical ideas to fill in my spotty understanding of all this greatly appreciated