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
Post a Comment