Hi Stefan
The event tells you that something happened and you don't get a chance to
"undo" it, so you'll need another strategy. You could add a mutex to your
"this" object, eg:
_onChangeValue: function(e) {
if (this.changingValue)
return;
this.changingValue = true;
.snip
this.changingValue = false;
}
or derive a class from Textfield and stop the keypress from being accepted
into the field in the first place.
John
From: Stefan Andersson <stefan.anders...@live.com>
Reply-To: qooxdoo Development <qooxdoo-devel@lists.sourceforge.net>
Date: Sun, 5 Sep 2010 14:39:43 +0200
To: <qooxdoo-devel@lists.sourceforge.net>
Subject: [qooxdoo-devel] How to stop oldValue to become a faulty value
creating recursion
The following setup:
textfield.addListener("changeValue", this._onChangeValue, this);
_onChangeValue : function(e)
{
var value = e.getData();
if(value > 0)
{
...
}
else
{
textfield.setValue(e.getOldData());
}
}
The problem is it creates recursion. Look at the value changing in the
textfield:
original: 3 -> normal in the function
type in: 0 -> function sets the textfield to the oldData 3, but the new
oldData becomes 0!!!!
type in: -1 ->function sets the textfield to the oldData 0 and the infinite
recursion started.
In this case there must be some way to not change the erroneous value to the
oldData like it works here.
If I call a throw new Error("Error!"); then the oldData is NEVER set to the
erroneous value!!! ...and it works!
I tried stop() which does not work and I can not see any other way except a
dirty clotty way: having a variable this.__data to buffer.........but it is
an unacceptable way.
Any other solution?
Stefan
----------------------------------------------------------------------------
-- This SF.net Dev2Dev email is sponsored by: Show off your parallel
programming skills. Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd________________________________________
_______ qooxdoo-devel mailing list qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:
Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel