Real Software Forums
http://forums.realsoftware.com/

SDK a little counter intuitive?
http://forums.realsoftware.com/viewtopic.php?f=24&t=47214
Page 1 of 1

Author:  neonash7777 [ Fri Mar 08, 2013 11:18 am ]
Post subject:  SDK a little counter intuitive?

I've read the WebControlSDK over a dozen times, and I'm still struggling to know what goes where to get things to work.

1)
From looking at the examples it appears I should put the Load Libraries event in the Open() event.
For LoadLibraries() I must also set a callback function.

But according to the documentation the order of events goes:
Open()
SetupHTML()
SetupCSS()
SetupJavaScriptFramework()

So it would be executing the callback before the HTML or even the javascript with the callback event exists.
Am I missing something here?

==========
2)
I have another question about the order of things.

I'm trying to make a Graph from some sample HTML of a Google Chart.
The HEADER has the
<script> tags
but BODY has the actual element.

Does the HTML get loaded before the header? In my head, I would have guessed that the Header would run before the Body, but since the header scripts are interacting with parts of the body, the body must exist first right?

==========
3)
I have a function:
RSCustom.<<Namespace>>.<<ControlId>>_constructor = function() {...}


But do I need to call the constructor, or is this something the wrapper class does automatically?
Should this be set as the callback? To me this doesn't make sense because I specify the callback event before this function even exists from the SetupJavascriptFramework() method.

In the constructor method I load some google libraries and call:
google.setOnLoadCallback(RSCustom.<<Namespace>>.<<ControlId>>_drawChart);

Does it matter that google is doing it's on OnLoadCallback?

Author:  neonash7777 [ Fri Mar 08, 2013 12:37 pm ]
Post subject:  Re: SDK a little counter intuitive?

4)
When I define a function

w3schools says to define a javascript function like this:
function RSCustom.<<Namespace>>.<<ControlId>>_constructor() {}


But when I do I get the error:
Quote:
Could not execute returned javascript: Unexpected token .


But when I define the function like this:
RSCustom.<<Namespace>>.<<ControlId>>_constructor = function() {}

I don't get the error, my Webcontrol just doesn't load and page turns blank.

Any idea why?

Author:  Stretch [ Fri Mar 08, 2013 4:56 pm ]
Post subject:  Re: SDK a little counter intuitive?

Quote:
From looking at the examples it appears I should put the Load Libraries event in the Open() event.
For LoadLibraries() I must also set a callback function.

But according to the documentation the order of events goes:
Open()
SetupHTML()
SetupCSS()
SetupJavaScriptFramework()

So it would be executing the callback before the HTML or even the javascript with the callback event exists.
Am I missing something here?


If you are calling LoadLibraries and specifying a callback, you must do so after adding your own code to the page, which should be done in SetupJavascriptFramework.

Quote:
But when I define the function like this:
RSCustom.<<Namespace>>.<<ControlId>>_constructor = function() {}
I don't get the error, my Webcontrol just doesn't load and page turns blank.


What does the javascript debugger in your browser say?

By the way... you ARE replacing <<Namespace>> and <<ControlId>> with your values, right?

Are you actually putting any code between the curly braces?

Author:  swort [ Fri Mar 08, 2013 5:52 pm ]
Post subject:  Re: SDK a little counter intuitive?

Use the examples, they helped me to go trough this.
I did not read the WebSDK pdf for creating my controls, but i read it just to see if it's useful.

I've created this audio control:
http://codecanyon.net/item/swort-webaud ... 11/4021222
You can preview it here:
http://webaudio.swort.eu/

You can buy the complete source code, it uses a framework i've created myself and it's fully commented to explain all steps taken.
It can be seen as an example, and audio control in one.

I use something like this (javascript framework):
RSCustom.swort.player ={
controlID: <<id>>,
init: function(){
}
}


in your RB code you return it like this:
Return ReplaceAll(MyFrameworkString, "<<id>>", me.controlID)


When your control is loaded, the shown event fires and you call ExecuteJavascript("RSCustom.swort.player.init();")
wich will do all my control initialisation (not the creation just the visual stuff)

Author:  neonash7777 [ Fri Mar 08, 2013 5:54 pm ]
Post subject:  Re: SDK a little counter intuitive?

Stretch wrote:
What does the javascript debugger in your browser say?

By the way... you ARE replacing <<Namespace>> and <<ControlId>> with your values, right?
Are you actually putting any code between the curly braces?


I use a ReplaceAll for namespace and controlID


This goes inside the curly braces:
google.load('visualization', '1.0', {'packages':['corechart']});
google.setOnLoadCallback(RSCustom.<<Namespace>>.<<ControlId>>_drawChart);

RSCustom.<<Namespace>>.<<ControlId>>_drawChart = function() {
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Topping');
data.addColumn('number', 'Slices');
data.addRows([
['Mushrooms', 3],
['Onions', 1],
['Olives', 1],
['Zucchini', 1],
['Pepperoni', 2]
]);

// Set chart options
var options = {'title':'How Much Pizza I Ate Last Night',
'width':400,
'height':300};

// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('<<ControlId>>'));
chart.draw(data, options);

}
});

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/