[comp.windows.x] text widget problem

yong%metasoft@bbn.com (01/31/89)

I have a textWidget which has about 20 chars displayed.
I would like certain substring to be replaced or redisplayed.
The textWidget is created as following:

        XtSetArg(textArgs[n],XtNeditType,XttextEdit);n++;
        XtSetArg(textArgs[n],XtNtextSink,XtAsciiSinkCreate(box,NULL,0));
                n++;
        source = XtStringSourceCreate(box,srcArgs,XtNumber(srcArgs));
        XtSetArg(textArgs[n],XtNtextSource,source);n++;
        XtSetArg(textArgs[n],XtNwidth,400);n++;
        XtSetArg(textArgs[n],XtNheight,400);n++;

        textWidget = XtCreateManagedWidget("text",textWidgetClass,box,
		textArgs,n);

I got the following message when the textWidget is realized:

	X Toolkit Warning: No type converter registered for 'String'
	to 'EditMode' conversion.

When I call to

	XtTextInvalidate(textWidget,1,10);
I got bus error:
	Bus error (core dumped)

	XtTextReplace(textWidget,1,10,&text);
	XtTextEnableRedisplay(textWidget);
    where text is as following:
		XtTextBlock text;
		text.ptr = newString;
	        text.firstPos = 1;
        	text.length = 10;

Am I doing anything wrong here?
Thank you in advance for you help!!!

************************************************************
Yongdeng Chen	yong%metasoft@bbn.com
		uunet!bbn!metasoft!yong

king@.sunysb.edu (01/31/89)

I am posting this for a friend. Please reply to

   yong%metasoft@bbn.com
   ...bbn!metasoft!yong


************************************************************
I have a textWidget which has about 20 chars displayed.
I would like certain substring to be replaced or redisplayed.
The textWidget is created as following:

        XtSetArg(textArgs[n],XtNeditType,XttextEdit);n++;
        XtSetArg(textArgs[n],XtNtextSink,XtAsciiSinkCreate(box,NULL,0));
                n++;
        source = XtStringSourceCreate(box,srcArgs,XtNumber(srcArgs));
        XtSetArg(textArgs[n],XtNtextSource,source);n++;
        XtSetArg(textArgs[n],XtNwidth,400);n++;
        XtSetArg(textArgs[n],XtNheight,400);n++;

        textWidget = XtCreateManagedWidget("text",textWidgetClass,box,
                textArgs,n);

I got the following message when the textWidget is realized:

        X Toolkit Warning: No type converter registered for 'String'
        to 'EditMode' conversion.

When I call to

        XtTextInvalidate(textWidget,1,10);
I got bus error:
        Bus error (core dumped)

        XtTextReplace(textWidget,1,10,&text);
        XtTextEnableRedisplay(textWidget);
    where text is as following:
                XtTextBlock text;
                text.ptr = newString;
                text.firstPos = 1;
                text.length = 10;

Am I doing anything wrong here?
Thank you in advance for you help!!!


Yongdeng Chen   yong%metasoft@bbn.com
                ...bbn!metasoft!yong

************************************************************

kit@ATHENA.MIT.EDU (Chris D. Peterson) (02/07/89)

> I got the following message when the textWidget is realized:

> 	X Toolkit Warning: No type converter registered for 'String'
> 	to 'EditMode' conversion.

This is a known bug in Xt that occures when you use XtCreateAppContext()
rather than XtInitialize() when starting up the toolkit.  We are currently
working on a slight redesign of Xt that is required to fix this particular
bug.  I bet this is causing the problems that you are noticing later in your
program.

Solutions:

1) Sit tight.  The fix will be made and posted for public distribution one of
   these days, but it could take awhile.

2) Use XtInitialize() to start up the toolkit.  The AppContext can be 
   retrieved by a call to XtWidgetToAppContext() on any widget in your 
   program.  This will cause problems if you are using multiple displays,
   however.

						Chris D. Peterson     
						MIT X Consortium /
						Project Athena 

Net:	kit@athena.mit.edu		
Phone: (617) 253 - 1326			
USMail: MIT - Room E40-321
	77 Massachusetts Ave.		
	Cambridge, MA 02139		

kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (04/13/90)

> In R3, I could type input, move the mouse
> cursor somewhere, depress the right mouse button, and the text
> between the caret (^) cursor and the mouse cursor would be selected.

Really?  I thought that the current behavior is the way it was in R3.  That's
one of the reasons why I didn't change it.  Do other people believe that his
has changed?  It has been so long since I have used a vanilla R3 system that I
have forgotten.  

In any case, I think that you are right, and the behavior that you suggest is
probabally the "right" thing to do, if you want to submit a bug report to
xbugs@expo I will add it to my (long) list of Text widget enhancements.
If you provide well thought out code it is more likely to get done.


						Chris D. Peterson     
						MIT X Consortium 

Net:	 kit@expo.lcs.mit.edu
Phone:   (617) 253 - 9608	
Address: MIT - Room NE43-213

swick@ATHENA.MIT.EDU (Ralph R. Swick) (04/13/90)

    >[scl]
    > In R3, I could type input, move the mouse
    > cursor somewhere, depress the right mouse button, and the text
    > between the caret (^) cursor and the mouse cursor would be selected.

    [kit]
     I thought that the current behavior is the way it was in R3.  That's
    one of the reasons why I didn't change it.  Do other people believe that his
    has changed?

Yes, it definitely did change from R3 initial release.  This was
a side-effect of a bug fix to the selection code for which I probably
was responsible.  The behaviour should definitely be restored to the
above description.