I have a text widget that is enabled for entry by the user, and which is also updated from the code (i.e. textWidget.setText(someValue))
I'm verifying for numeric using a verify listener
txtSeq.addVerifyListener((e)-> {
e.doit = Character.isDigit(e.character) || e.character == '\b';
});
What is unexpected is that when I call setText() from other code, the verify listener gets invoked with a VerifyEvent containing a single null byte (0x00) as the character.
VerifyEvent{Text {} time=706277578 data=null character='\0'=0x0
keyCode=0x0 keyLocation=0x0 stateMask=0x0 doit=true start=0 end=1 text=}
My verify listener considers that invalid and discards it, and this prevents text widget's text from being updated. As a workaround I changed the verify listener to accept 0x00 as well as numerics and backspace.
e.doit = Character.isDigit(e.character) || e.character == '\b' || e.character == '\0';
Question
Is this behavior documented anywhere, and is this the correct way to handle the issue?