PDA

View Full Version : Subclassing and new classes


Nic
06-22-2004, 06:40 AM
Hi,

As a newbie to Laszlo, I am struggling to understand the best way to build a custom control.

I see two ways:

1. Create a new class by extending a control
2. Create a new class and embed other elements.

I have gone for the second one as it appears to be the easiest way to control the look and feel.

I have created a new class that embeds an imputtext box. I have done this to allow me to create border around the control. Result is an input text box with a border. However I also want to be able to capture events from the input text box in the new class. i.e. make the input box with the border behave like a normal input text.

For instance if I have an onblur fire on the input text, how do I call the custom code in my instantiation of the custom class.

I have declared an instance of my custom class as:

<mytextfield name="fName" label="First Name">
<method name="error">
debug.write("blurring custom error...");
</method>
</mytextfield>

I want error to be called when the onblur event fires on the inputtext box. I need this to allow me to define a different piece of code for each instantiation of the mytextfield.

Any pointers on how exactly to do this is much appreciated.

Thanks in advance

Nic

antun
06-22-2004, 10:58 AM
We have just released our developers guide BETA: "Designing, Developing, and Deploying Laszlo Applications", and there happens to be a detailed chapter on just what you're doing:

http://www.laszlosystems.com/lps-2.2b1/docs/developers-guide/custom-components.html

Normally I hate it when people tell me to read the manual, but in this case, I figured you could give us some feedback as to whether it answered everything you needed to know. Like I said this is a BETA of the documentation, so developer opinion is really important to us. By all means let me know if it doesn't, and I'll be more than happy to help.

-Antun

Nic
06-23-2004, 03:07 AM
Great I'll take a look thanks.