Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Text widget verify event with '\x00' character
Text widget verify event with '\x00' character [message #1836079] Sun, 20 December 2020 00:44
James Garrison is currently offline James GarrisonFriend
Messages: 16
Registered: July 2009
Junior Member
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';

Is this behavior documented anywhere, and is this the correct way to handle the issue?
Previous Topic:SWT EOL versions?
Next Topic:Input fields that also get set from within the program
Goto Forum:

Current Time: Thu Apr 15 06:12:07 GMT 2021

Powered by FUDForum. Page generated in 0.01952 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top