I have to make a design decision now.
All the controls are being created by functions.
These functions could be converted in objects easily. It is very easy in JavaScript. We must invoke them with 'new' and use 'this' inside function when required.
The question is: ¿Is this necessary?
When we create an element (by any means) it is already an object for our browsers. So, we can access to its properties, events and methods via Document Object Model (DOM).
A clear example of this, is in the TextBox demo:
Code: Select all
function test_3() // TextBox Demo
{
oWindow = new Window( "Hello World!", 600 , 300 );
TextBox( "text_1" , oWindow , 130, 230, "TextBox!" );
Button( 'button_1' , oWindow , 240 , 110 , "Get TxtBox Value" , "MsgInfo(document.getElementById('text_1').value,'TextBox Value')" );
Button( 'button_2' , oWindow , 240 , 240 , "Set TxtBox Value" , "document.getElementById('text_1').value = 'New Value' " );
Button( 'button_3' , oWindow , 240 , 370 , "Close" , "oWindow.Release()" );
}
We are accesing the 'native' value property of the textbox (input text element) via
document.getElementById('text_1').value.
To use the control creation functions as objects, we should construct a complete layer over each control, but ¿is that really necessary?
We don't need to know the answer right now, because it can be done at any moment, building on top the current code without loosing compatibility.
The problem that must be solved right now, is, if the window must be treated as an object or not.
The Window is currently an object, only because it requires two different elements (one div for the cover and another for window itself).
So, when we need to release the window, we must to remove its cover too.
This is currently generating some sort of consistency problem, since, IMHO, windows and controls should be treated in the same way.
A solution to create the windows in the same way as controls, is to detach the the window div from the cover that makes it modal, this way we could handle the window div directly via DOM (the same as controls).
I'm thinking about that, so, I've pressed pause on the library development.
Any other idea or suggestion is welcome.