home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12712 < prev    next >
Encoding:
Text File  |  1992-08-20  |  1.6 KB  |  64 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!jvnc.net!nuscc!iscooibc
  3. From: iscooibc@nuscc.nus.sg (Beng Chin)
  4. Subject: Actions not found error!
  5. Message-ID: <1992Aug21.101547.24362@nuscc.nus.sg>
  6. Organization: National University of Singapore
  7. Date: Fri, 21 Aug 1992 10:15:47 GMT
  8. Lines: 54
  9.  
  10.  
  11. Hi,
  12.  
  13. I would like to add a translation (actually to overide) which
  14. would cause a widget to activate a callback when selected.
  15.  
  16. However, when I run the program, it always give me a run-time
  17. error of
  18.  
  19. Warning: Actions not found: selectCallback.
  20.  
  21. This is how I use the WidgetAction:
  22.  
  23. action = new WidgetAction();
  24. action->addTranslate( <a widget> );
  25.  
  26. I am using C++ with Motif. Appreciate help
  27. of any kind. Thanks!
  28.  
  29. KC Phua
  30. National U. of Singapore
  31.  
  32. ---------------------- cut here ------------------------
  33.  
  34. WidgetAction Class
  35. ------------------
  36. :
  37. :
  38. :
  39. void WidgetAction::selectCallback( Widget w, XEvent *event,
  40.     XtPointer clientData ) {
  41.     WidgetAction *obj = (WidgetAction *) clientData; 
  42.     obj->select( w, event );
  43. }
  44.  
  45. void WidgetAction::select( Widget w, XEvent *event ) {
  46.     ...................
  47. }
  48.  
  49. void WidgetAction::addTranslate( Widget w ) {
  50.     static char defaultTranslations[] = 
  51.     "None<Btn1Down>: selectCallback()";
  52.     static XtActionsRec actionsTable[] = {
  53.     { "select", (XtActionProc) &WidgetAction::selectCallback },
  54.     };
  55.     XtTranslations trans_table;
  56.     XtAddActions(actionsTable, XtNumber(actionsTable));
  57.     trans_table = XtParseTranslationTable(defaultTranslations);
  58.     XtVaSetValues( w,
  59.                    XmNtranslations, trans_table,
  60.                    NULL );
  61.     XtOverrideTranslations(w, trans_table);
  62. }
  63.  
  64.