I would rather make a white list of the characters you WANT ;-)
On 12 Sep., 10:00, "Fred Janon" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> You can remove:
>
> && (keyCode != (char) KEY_TAB)
> && (keyCode != (char) KEY_BACKSPACE)
> && (keyCode != (char) KEY_DELETE) && (keyCode !=
> (char)
> KEY_ENTER)
> && (keyCode != (char) KEY_HOME) && (keyCode !=
> (char)
> KEY_END)
> && (keyCode != (char) KEY_LEFT) && (keyCode !=
> (char)
> KEY_UP)
> && (keyCode != (char) KEY_RIGHT) && (keyCode !=
> (char)
> KEY_DOWN)) {
>
> This is a mistake in the GWT example. These codes are for onKeyUp and
> onKeyDown, they don't work for onKeyPress. KEY_DELETE has the same value as
> '.' and will get you into trouble. onKeyPress gets a char passed in, not a
> keyCode. My advice is to remove them and test your field with all the
> characters you don't want.
>
> Fred
>
> On Fri, Sep 12, 2008 at 14:36, jagadesh <[EMAIL PROTECTED]> wrote:
>
> > Thanks Man,
>
> > I have disabled all the special characters but i need to use only "%"
> > Character. i used the following code.
>
> > ((TextBox)searchTable.getWidget(9,2)).addKeyboardListener(new
> > KeyboardListenerAdapter() {
> > public void onKeyPress(Widget sender, char keyCode,
> > int
> > modifiers) {
> > if ((!Character.isLetter(keyCode))&& (!
> > Character.isDigit(keyCode))
> > && (keyCode != (char) KEY_TAB)
> > || (keyCode =='.')
> > || (keyCode =='#')
> > || (keyCode =='$')
> > || (keyCode =='(')
> > || (keyCode !='%')
> > && (keyCode != (char) KEY_BACKSPACE)
> > && (keyCode != (char) KEY_DELETE) && (keyCode !=
> > (char)
> > KEY_ENTER)
> > && (keyCode != (char) KEY_HOME) && (keyCode !=
> > (char)
> > KEY_END)
> > && (keyCode != (char) KEY_LEFT) && (keyCode !=
> > (char)
> > KEY_UP)
> > && (keyCode != (char) KEY_RIGHT) && (keyCode !=
> > (char)
> > KEY_DOWN)) {
> > // TextBox.cancelKey() suppresses the current
> > keyboard
> > event.
> > ((TextBox)sender).cancelKey();
> > }
> > }
> > });
>
> > Thank U.
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" 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-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---