[comp.windows.x.motif] Text widgets - vetting characters for delete or add

Paul.Quane@samba.acs.unc.edu (BBS Account) (10/02/90)

I have yet to try this but am about to this afternoon - maybe I should wait...
naaah... you can try this too and see if it works.

Text widgets have a modifyVerifyCallback resource which callbacks defined
for get called BEFORE text is added to or deleted from the widget.
The structure returned by the widget has a doit field which if set to false
means that the insert/delete will not be performed.
The Callback information includes the text position and the text details.
In the callback you should examine the position of the insert cursor
(calldata->currInsert), the desired new position of the insert cursor 
( calldata->newInsert) to ascertain if delete or add. 
If it is a delete there may be more than one character .
Go through the text (calldata->text->ptr) 
looking for a : or / ( these are the characters you want to stay - yeah ?). 
If you find one then you have two choices.

1) disallow the delete entirely ( say user tries to delete tyu:99 ) by
   setting the doit flag in the callback struct to False

2) play around with the callback->text->ptr string taking out the characters
   the users are allowed to delete and leaving in the ones they are not, leaving
   the callback->doit set to its default value True. ( tyu:99 would become 99,
   assuming delete was from right to left )
   Of course this is more difficult because the start and end text positions 
    must be changed to reflect the modified delete request and the user
   still has to go and delete the remaining text bordering the non deletable
   character in the example case given, and might be confusing for the poor
   persons. 

Anyway the manual can explain it much better than I can so read the 
XmText page and go have some fun...
   
Paul Quane
Datronics Inc. at GTE Government Systems, RTP, NC
--