Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Wed Sep 20, 2017 6:49 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: SDK a little counter intuitive?
PostPosted: Fri Mar 08, 2013 11:18 am 
Offline
User avatar

Joined: Mon Nov 29, 2010 7:01 pm
Posts: 446
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?


Top
 Profile  
Reply with quote  
 Post subject: Re: SDK a little counter intuitive?
PostPosted: Fri Mar 08, 2013 12:37 pm 
Offline
User avatar

Joined: Mon Nov 29, 2010 7:01 pm
Posts: 446
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?


Top
 Profile  
Reply with quote  
 Post subject: Re: SDK a little counter intuitive?
PostPosted: Fri Mar 08, 2013 4:56 pm 
Offline
Real Software Engineer

Joined: Tue Jul 14, 2009 4:33 pm
Posts: 146
Location: Raleigh, NC
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?

_________________
Greg O'Lone
Software Engineer
Real Software


Top
 Profile  
Reply with quote  
 Post subject: Re: SDK a little counter intuitive?
PostPosted: Fri Mar 08, 2013 5:52 pm 
Offline

Joined: Mon May 31, 2010 5:35 am
Posts: 2412
Location: Netherlands
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)

_________________
SWORT™
- Windows Vista, Windows XP, Windows 7, Linux Mint 11 and Mac OSX Lion
- REAL Studio Enterprise(latest) and WEB Edition(latest)
- Plugins (MBS Complete, ToringoLib, Einhugur, VanHoek + Some open source plugins)
For Dutch User Groups ask me to enter!


Top
 Profile  
Reply with quote  
 Post subject: Re: SDK a little counter intuitive?
PostPosted: Fri Mar 08, 2013 5:54 pm 
Offline
User avatar

Joined: Mon Nov 29, 2010 7:01 pm
Posts: 446
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);

}
});


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group