Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!sun!pitstop!sundc!seismo!uunet!mcvax!ukc!dcl-cs!de From: de@comp.lancs.ac.uk (David England) Newsgroups: comp.windows.x Subject: Losing chars to a pop-up Message-ID: <718@dcl-csvax.comp.lancs.ac.uk> Date: 6 Mar 89 13:27:32 GMT Reply-To: de@comp.lancs.ac.uk (David England) Organization: Department of Computing at Lancaster University, UK. Lines: 66 I writing a graph editor and want to have editable text labels. At the moment I pop up a text widget when the user clicks the mouse in the parent window and then starts typing. The first letter pops up the asciiStringWidget. However any text typed after the first character and before the widget appears is lost. I've tried buffering up these characters and adding them to the text source but there's always a delay between setting the text source and the appearance of the widget. Does anyone have any better ideas e.g. using selection buffers and pasting that in ? (Don't know how to do that) Here's my current attempt; char * pop_up_text(ch, textX, textY) int ch; int textX; int textY; { static Arg popup_args[]={ {XtNx, (XtArgVal)0}, {XtNy, (XtArgVal)0} }; int new_x, new_y; char buffer[2]; Window tempchild; if (isalpha(ch)) { sprintf(buffer,"%c",ch); sprintf(textBuffer,"%s",buffer); fprintf(debug_fp,"text buffer before %s\n",textBuffer); } textLabel = makeStringBox(textBox, textBuffer, 120,1); XtTextSetInsertionPoint(textLabel, 1); XtSetKeyboardFocus(textBox, textLabel); XTranslateCoordinates(display, XtWindow(editCanvas), root, textX, textY, &new_x, &new_y, &tempchild); popup_args[0].value = (XtArgVal)new_x; popup_args[1].value = (XtArgVal)new_y; /* pop_up via Xtk routines @ new_x, new_y*/ XtSetValues(textPopup, popup_args, XtNumber(popup_args)); XtPopup(textPopup, XtGrabNone); return (textBuffer); } appendToken(ch) int ch; { char buffer[2]; if (isalpha(ch)) { sprintf(buffer,"%c",ch); strcat(textBuffer,buffer); fprintf(debug_fp,"text buffer before %s\n",textBuffer); } } -- uucp: ...!mcvax!ukc!dcl-cs!de or: ...!uunet!comp.lancs.ac.uk!de arpa/janet: de@comp.lancs.ac.uk "The Bluebird of happiness long absent from his life, Ned is visited by the chicken of depression"