Hello Ray,
thats all working right out of the box. I used the value to apply the filter and not the keypress events like in the snippet. That way I don't even have to take care of the special keys like backspace.
Greetings,
Martin


Am 03.07.2009 um 15:49 schrieb Raymond Cote:

Thanks Martin,

I'll probably be updating to trunk shortly and will look at this example.

In the example you give, how would you setFilter for digits plus backspace, left/right arrows, begin/end, etc. to allow navigation in the field?

I added an if statement looking for the individual key identifiers, but don't know if there's a more "qooxdoo" way to do that. Perhaps the ability to specify that all navigation-class keystrokes are allowed?
--Ray



Martin Wittemann wrote:

Hello Ray,

is just added exactly that feature to the framework. So if you are using the trunk of qooxdoo, you could enable the filter in one line:
textfield.setFilter(/[0-9]/);

Best,
Martin

Am 02.07.2009 um 14:39 schrieb Raymond Cote:

Alexander Back wrote:

Hi Ray,

On Wednesday 01 July 2009 Raymond Cote wrote:

I have a TextField which I'd like to limit to accepting only digits.

I've added a listener to the TextField and can grab each keystroke as it
is entered.

However, I'm unclear as to how I could decide whether or not to let this
keystroke through.
The TextField is not being updated until after I receive the keystroke, so I suspect there's something I can do to say "not this keystroke."

Here's a little snippet that does the job:

--snip--
t = new qx.ui.form.TextField("");
this.getRoot().add(t);

t.addListener("keypress", function(e){
    if(e.getKeyIdentifier().search(/[0-9]/) == -1) {
      e.preventDefault();
    }
});
--snip--

The magic line is the one with the "preventDefault" method. This way you tell the browser to not perform the default behaviour. In our case here it is to
fill the textfield with the pressed key.

cheers,
  Alex


------------------------------------------------------------------------------
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Excellent! Just the key I needed.
Thanks
--Ray

------------------------------------------------------------------------------
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


------------------------------------------------------------------------------


_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


------------------------------------------------------------------------------
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

------------------------------------------------------------------------------
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to