Hi Sikd,

yes, you can pass the reference from the function. Your example is 
nearly correct, only the bracket are sometimes wrong:

<code>
var currentFunction = qx.myFunctions.myFunction1; // <- no bracket necessary
var myButton1 = new qx.myButton(currentFunction);

var currentFunction = qx.myFunctions.myFunction2; // <- no bracket necessary
var myButton2 = new qx.myButton(currentFunction);
</code>

In the constructor you can call the function like:

<code>
construct: function(currFn) {
   this.addListener("click", function(e) {
        currFn(); //<-- here a the bracket necessary
   });
});
</code>

Cheers,
Chris


sikd schrieb:
> My programming skill is not enough to solve this problem. Hope someone could
> help me.
>
> I have a class "myButton" which made a simple button.
> I have a static class "myFunctions" which conatains myFunction1(),
> myFunction2() and so on.
>
> I would like to make instances of myButton class: myButton1, myButton2...
> Is it possible to pass the appropriate myFunction() to the myButton
> constructor, something like this:
>
> <code>
> var currentFunction = qx.myFunctions.myFunction1();
> var myButton1 = new qx.myButton(currentFunction);
>
> var currentFunction = qx.myFunctions.myFunction2();
> var myButton2 = new qx.myButton(currentFunction);
> </code>
>
> And in the myButton constructor something like this:
>
> <code>
> construct: function(currFn) {
>    this.addListener("click", function(e) {
>         currFn;
>    });
> });
> </code>
>   


-- 
Christian Schmidt
Software Entwickler

1&1 Internet AG - Web Technologies
Ernst-Frey-Straße 9 · DE-76135 Karlsruhe
[email protected]

Amtsgericht Montabaur / HRB 6484
Vorstände: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Thomas 
Gottschlich, Robert Hoffmann, Markus Huhn, Hans-Henning Kettler, Dr. Oliver 
Mauss, Jan Oetjen
Aufsichtsratsvorsitzender: Michael Scheeren


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to