home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / windows / x / motif / 5566 < prev    next >
Encoding:
Internet Message Format  |  1992-08-12  |  2.5 KB

  1. Path: sparky!uunet!ogicse!amb4.ese.ogi.edu!pturner
  2. From: pturner@amb4.ese.ogi.edu (Paul J Turner)
  3. Newsgroups: comp.windows.x.motif
  4. Subject: Need help using PushButton as ToggleButton
  5. Keywords: PushButton, Arm, Disarm, ToggleButton
  6. Message-ID: <41238@ogicse.ogi.edu>
  7. Date: 12 Aug 92 15:41:42 GMT
  8. Article-I.D.: ogicse.41238
  9. Sender: news@ogicse.ogi.edu
  10. Followup-To: pturner@amb4.ese.ogi.edu
  11. Distribution: usa
  12. Organization: Center for Coastal and Land-Margin Research
  13. Lines: 61
  14. Originator: pturner@amb4.ese.ogi.edu
  15.  
  16. Ideally, I'd like to use a ToggleButton with no label and
  17. a Pixmap of my choosing for the toggle - but I wasn't able to
  18. to do this. This would be the ideal solution - what follows is 
  19. something that almost works.
  20.  
  21. I'm trying to use PushButtons with Pixmaps as toggle buttons
  22. using arm/disarm to indicate the state of the associated boolean
  23. variable. Things work fine provided the initial state on startup is 
  24. False (button is in a disarmed state). The problem is initializing
  25. the button to an armed state - the button appears depressed as long
  26. as the pointer does not traverse the PushButton. When the pointer
  27. does cross the PushButton, it becomes disarmed when the pointer leaves
  28. the border of the PushButton's Pixmap. Crossing the PushButton again
  29. will cause the button to display as armed, but only as long as the
  30. pointer is in the borders of the Pixmap. Clicking on the PushButton
  31. a couple of times straightens it out, so the correct state is displayed
  32. regardless of the position of the pointer.
  33.  
  34. The button is created as follows, set to an armed state, parent is
  35. a RowColumn:
  36.  
  37.     bt = XtVaCreateManagedWidget("golly", xmPushButtonWidgetClass, rc, 
  38.                   XmNlabelType, XmPIXMAP,
  39.                   XmNlabelPixmap, gollypm,
  40.           NULL);
  41.     XtAddCallback(bt, XmNactivateCallback, toggle_golly_proc, GOLLY_VAL);
  42. /*
  43.  * this button's initial state is True, so display as armed
  44.  */
  45.     XtCallActionProc(bt, "Arm", NULL, NULL, 0);
  46.                                 ^^^^ I think the problem is here,
  47.                      should be an event. But how
  48.                      is it defined?
  49.  
  50. While the program is running, the button is toggled using:
  51.  
  52. void toggle_golly_proc(w, cd, cbs)
  53. Widget w;
  54. int cd;
  55. XmAnyCallbackStruct *cbs;
  56. {
  57.     switch (cd) {
  58.     case GOLLY_VAL:
  59.         if (do_golly) {
  60.             XtCallActionProc(w, "Disarm", cbs->event, NULL, 0);
  61.             do_golly = 0;
  62.         } else {
  63.             XtCallActionProc(w, "Arm", cbs->event, NULL, 0);
  64.             do_golly = 1;
  65.         }
  66.     }
  67. }
  68.  
  69. This works just fine.
  70.  
  71. Any clues would be appreciated.
  72.  
  73. Thanks,
  74.  
  75. Paul J Turner
  76. pturner@amb4.ese.ogi.edu
  77.