Hi Derrell, wouldn't it make sense to ask for addition of this directly to the qx.core.Object? Or to at least add your mixin to the standard distribution?
Cheers, Fritz On Mon, 3 May 2010, Derrell Lipman wrote: > On Mon, May 3, 2010 at 10:24, Daniel Wagner <[email protected]> wrote: > >> Hi Burak, >> >> Martin agrees it shouldn't be a big deal to add a context parameter, so >> feel free to open a bug report. >> >> In the mean time, you can use qx.lang.Function.bind to set the context >> of your validator function. >> > > And if you find yourself using the static method qx.lang.Function.bind(...) > a lot and would prefer to be able to just say this.bind(...) you use this > code in your applicaiton: > > // Add a bindTo() method to qx.core.Object as a shortcut to constantly > // having to use qx.lang.Function.bind() > qx.Class.include(qx.core.Object, custom.MObject); > > Here's the actual mixin to add to your project: > > /* ************************************************************************ > > Copyright: > 2009 Derrell Lipman > > License: > LGPL: http://www.gnu.org/licenses/lgpl.html > EPL: http://www.eclipse.org/org/documents/epl-v10.php > See the LICENSE file in the project's top-level directory for details. > > Authors: > * Derrell Lipman (derrell) > > ************************************************************************ */ > > /** > * Mixin to add a bindTo method to qx.core.Object > */ > qx.Mixin.define("custom.MObject", > { > members : > { > /** > * Bind a function to this object > * > * @param func {Function} > * The function to be bound > * > * @param varargs {Any?} > * Optional arguments to be passed to the function. > * > * @return {Function} > * A wrapped version of the function that binds 'this' to the > * user-provided function. > */ > bindTo : function(func, varargs) > { > return qx.lang.Function.create( > func, > { > self : this, > args : (arguments.length > 1 > ? qx.lang.Array.fromArguments(arguments, 1) : > null) > }); > } > } > }); > -- Oetiker+Partner AG tel: +41 62 775 9903 (direct) Fritz Zaucker +41 62 775 9900 (switch board) Aarweg 15 +41 79 675 0630 (mobile) CH-4600 Olten fax: +41 62 775 9905 Schweiz web: www.oetiker.ch ------------------------------------------------------------------------------ _______________________________________________ qooxdoo-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
