home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / windows / openloo / 3441 < prev    next >
Encoding:
Text File  |  1992-08-13  |  2.2 KB  |  74 lines

  1. Newsgroups: comp.windows.open-look
  2. Path: sparky!uunet!mcsun!sunic!sics.se!eua.ericsson.se!tvtjet
  3. From: tvtjet@eua.ericsson.se (Jorgen Eriksson)
  4. Subject: Re: Retrieving XtNstring from TextField
  5. Message-ID: <1992Aug13.122419.15894@eua.ericsson.se>
  6. Sender: news@eua.ericsson.se
  7. Nntp-Posting-Host: euas20c01.eua.ericsson.se
  8. Organization: Ellemtel Telecom Systems Labs, Stockholm, Sweden
  9. References: <1992Aug13.001628.8075@informix.com>
  10. Date: Thu, 13 Aug 1992 12:24:19 GMT
  11. Lines: 61
  12.  
  13. Hello David !
  14.  
  15. I didn't manage to email you, it bounced... Anyway here's my reply:
  16. I can spot two problems with your code example:      
  17. 1. I don't think you can retrieve data from a widget that isn't realized.
  18. 2. This is a classical one, i and all my Xt hacking friends have been doing this   "pointer thing" numerous times. Here is a small code example, i'm sure
  19.    you will recognize most of it:
  20. #include <X11/Intrinsic.h>
  21. #include <X11/StringDefs.h>
  22. #include <X11/Shell.h>
  23. #include <Xol/OpenLook.h>
  24. #include <Xol/TextField.h>
  25. #include <stdio.h>
  26.  
  27. #define MAXARGS 20
  28. #define MAXMSGSIZE 200
  29. #define VISMSGSIZE 20
  30.  
  31. void    textCB();
  32.  
  33. int main(argc, argv)
  34. int argc;
  35. char **argv;
  36. {
  37.         Widget  toplevel, msgField;
  38.         Arg     args[MAXARGS];
  39.         Cardinal n;
  40.  
  41.         toplevel = OlInitialize("top","Top", NULL, 0, &argc, argv);
  42.  
  43.         n = 0;
  44.         XtSetArg(args[n], XtNmaximumSize, (XtArgVal) MAXMSGSIZE);       n++;
  45.         XtSetArg(args[n], XtNcharsVisible, (XtArgVal) VISMSGSIZE);      n++;
  46.         XtSetArg(args[n], XtNstring, "test"); n++;
  47.         msgField = XtCreateManagedWidget("textfield",
  48.                                 textFieldWidgetClass, toplevel, args, n);
  49.         XtAddCallback(msgField, XtNverification, textCB, NULL);
  50.  
  51.         XtRealizeWidget(toplevel);
  52.         XtMainLoop();
  53. }
  54.  
  55. void textCB(w, client_data, call_data)
  56. Widget w;
  57. caddr_t client_data, call_data;
  58. {
  59.         Arg             args[10];
  60.         char            *p, temp[100];
  61.         int             temp2, n;
  62.  
  63.         n = 0;
  64. /* Ok here it comes... */
  65.         XtSetArg(args[n], XtNstring, &p); n++;
  66.         XtGetValues(w, args, n);
  67.         fprintf(stdout, "string = %s\n", p);
  68.  
  69. }
  70. ------------------------------------------------------------
  71. Greetings 
  72.         Jorgen (Jorgen.Eriksson@eua.ericsson.se)
  73.  
  74.