java - how to validate SWT textbox to allow '*' character in it? -


i trying validate swt textbox accept alphanumerics, '.' , '*' characters, user able enter wildcard patterns (e.g.- *.txt).

with below code not able input '*' character(with * button in num pad of keyboard also). please help.

text.addverifylistener(new verifylistener() {     @override     public void verifytext(verifyevent e) {         e.doit=character.isletterordigit(e.character)             ||e.keycode=='.'             ||e.keycode=='*'             ||e.keycode==swt.arrow_left             ||e.keycode==swt.arrow_right             ||e.keycode==swt.bs;      } }); 

you testing keycode field against character - key code value not same character value. use:

|| e.character == '.' || e.character == '*' 

or if want allow keypad . * use:

|| e.keycode == swt.keypad_decimal || e.keycode == swt.keypad_multiply 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -