home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / sgi / graphics / 129 < prev    next >
Encoding:
Text File  |  1993-01-12  |  2.3 KB  |  77 lines

  1. Newsgroups: comp.sys.sgi.graphics
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!dog.ee.lbl.gov!news!vela!sglanger
  3. From: sglanger@vela.acs.oakland.edu (LANGER STEVEN C)
  4. Subject: motif text widgets
  5. Message-ID: <1993Jan13.040941.4854@vela.acs.oakland.edu>
  6. Organization: Oakland University, Rochester MI.
  7. Distribution: na
  8. Date: Wed, 13 Jan 1993 04:09:41 GMT
  9. Lines: 66
  10.  
  11. Hi folks;
  12.   Another question, this time on text widgets. I have a dialog with
  13. several one line text widgets attached to it. To the right of each
  14. text widget is a button. When the button is pressed, I want new text to show
  15. up in the assocaited text widget.
  16.  
  17. ________________________________________________
  18. |
  19. | text1 b1
  20. | text2 b2
  21. |
  22. |
  23.  
  24. the code fragment is
  25. {
  26.     dialog = XmCreateDialogShell (toplevel, ...
  27.  
  28.     form = XmCreateForm (dialog, ...
  29.  
  30.     text1 = XmCreateTextWidget (form, attach upper left
  31.     b1  = XmCreatePushButton (form, attach to right of text widget
  32.  
  33.     XtAddCallback (b1, XmNactivateCallback, cbfunc, "b1");
  34.     XtManageChild (form);
  35.     XtManageChild (dialog);
  36. }
  37.  
  38. void cbfunc (Widget w, XtPointer data, XtPointer dummy)
  39. {
  40.     char *text;
  41.     char str[]="here i am";
  42.  
  43.     if (strcasecmp(data, "b1") == 0)
  44.     {
  45.         temp = XtMalloc (sizeof(str));
  46.         temp[sizeof(str)] = 0    ;    /* null terminator */
  47.         XmTextSetString (w, text);
  48.         XtFree (text);
  49.     }
  50.  
  51. }
  52.  
  53. This is my adaptation of Heller's example 15-2 file browser.c
  54. program. The cbfunc is based on read_file.
  55.  
  56.  
  57. The dialog is created and the default text is drawn, but when the b1
  58. is pressed, I get a core dump and dbx zeros in on the
  59. XmTextSetString call.
  60.  
  61. Any ideas on how to beat this?
  62.  
  63. --thanks in advance, steve
  64.  
  65. -- 
  66. Steve Langer                     sglanger@argo.acs.oakland.edu (VMS)
  67. Oakland University               sglanger@vela.acs.oakland.edu (Ultrix)
  68. ---------------------------------------------------------------------------
  69. Standard disclaimers apply. In addition, the author makes no guarantees,
  70. concerning the grammatical accuracy of his writing. Therefore, any ^B's, ^C's, 
  71. midword character additions/deletions and other non-sense which occurs (after 
  72. the work leaves the author's decade old text editor via his decade old Amiga, 
  73. struggles through a local 1200 baud Merit server to be further mauled via the 
  74. remote VAX mail servers) is someone elses problem - namely yours.
  75. ---------------------------------------------------------------------------
  76.