I'd like to be able to define functions for every possible label,
including labels that might get added later, rather than for a single
label. Extending the existing label class would be the right way to do
this. Of course there are other ways (I'm using them now), I was just
hoping for something cleaner.
Well, if there's no way to extend element classes or basicElement
itself, perhaps Google can consider this a feature request?
On Sep 18, 3:06 am, Teo <[EMAIL PROTECTED]> wrote:
> Hi,
> i don't think that's possible. Why don't you encapsulate the label in a
> Javascript object, and you'll be able to define any function you want for
> it.
>
> Thanks,
> Teo
>
>
>
> On Thu, Sep 18, 2008 at 11:45 AM, Steve Simitzis <[EMAIL PROTECTED]> wrote:
>
> > Hello -
>
> > I would like to add a method to one of the element classes. Is this
> > possible?
>
> > So let's say I have -
>
> > <label name="chickens" x="5" />
>
> > And let's say for example, I would like to do this in my code:
>
> > var x = chickens.getX();
>
> > Ideally I would do that by adding a function like this:
>
> > label.prototype.getX = function() { return this.x; }
>
> > (Of course, this is a lame example, since there's no reason to write a
> > function just to return the value of x. But there are reasons you
> > might want to define a new method.)
>
> > Now when I actually try it, I get an error that label.prototype is
> > undefined. So clearly I'm missing something. Either there's no way to
> > modify an element class, or it's named something other than "label".
>
> > thanks!
>
> --
> Teo (a.k.a. Teodor Filimon, Teominator)
> Site -www.teodorfilimon.com| Blog -www.teodorfilimon.blogspot.com
> GMT +2 (or PDT +10)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Desktop Developer Group" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Google-Desktop-Developer?hl=en
-~----------~----~----~----~------~----~------~--~---