dvb@emisle.emisle (David Van Beveren) (03/25/91)
This seems so easy, but I just cannot make it work: Goal: create a function that is passed a prompt string and a default response string. This function pop up an APPLICATION_MODAL dialog shell with a PROMPT MessageBox as its only child. The routine will return the string typed in, which defaults to the passed default response, or NULL if the cancel button is pressed. Solution: Easy, at initialization create a dialog shell and a selection box of the appropriate type. This routine is called bldprompt(). neither widget is managed at creation time, but they are realized. the main routine is called get_input, and it first manages the widgets, calls XmProcessTraversal passing the DIALOG_TEXT child of the selection box and XmTRAVERSE_CURRENT. Then, go into a x-loop which will terminate when a control variable is changed. The control variable is changed by either the XmNokCallback or the XmNcancelCallback. Those callbacks extract the string from the DIALOG_TEXT child, and the main routine gets that string and returns it. Bug: The first time the widget is managed, the text child does not get focus. Instead, a little caret appears after the text (I use XmTextSetString and XmTextSetInsertionPosition (sic?) to set the default and position the cursor). This only happens the first time. After that, whenever the get_input routine is called, everything works fine. I believe the problem is that some X-events need to be processed on the text widget after XtManageChild has been called and before XmProcessTraversal can be called. I do not know what these events might be. If I knew, I might be able to insert an event handler after all others that calls XmProcessTraversal for the text widget. (I tried this for Exposure and got no difference) If anyone has Ideas, or even better, code that does this, please let me know. I will summarize and post of there is sufficient interest. -- David Van Beveren INTERNET: emisle!dvb@ism.isc.com EIS ltd. Professional Software Services UUCP: ..uunet!emisle!dvb voice: (818) 587-1247