home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / windows / x / motif / 8918 < prev    next >
Encoding:
Text File  |  1993-01-29  |  5.4 KB  |  176 lines

  1. Newsgroups: comp.windows.x.motif
  2. Path: sparky!uunet!math.fu-berlin.de!ira.uka.de!scsing.switch.ch!univ-lyon1.fr!ghost.dsi.unimi.it!rpi!news.ans.net!newsgate.watson.ibm.com!yktnews!admin!kendal!dao
  3. From: dao@rchland.vnet.ibm.com (Dan Dao)
  4. Subject: New widget and keyboard focus
  5. Sender: news@rchland.ibm.com
  6. Message-ID: <1993Jan28.151724.27891@rchland.ibm.com>
  7. Date: Thu, 28 Jan 1993 15:17:24 GMT
  8. Reply-To: dao@rchland.vnet.ibm.com
  9. Disclaimer: This posting represents the poster's views, not necessarily those of IBM
  10. Nntp-Posting-Host: kendal.rchland.ibm.com
  11. Organization: IBM Rochester
  12. Lines: 162
  13.  
  14.  
  15. -- 
  16. I'm writing a new widget and having some problem with keyboard focus.
  17. What I have inside the new widget are:
  18.  
  19. 1-foundation (Form widget)
  20. 2-entry window(Text widget) child of foundation
  21. 3-scroll window(Scrolled widget) child of foundation
  22. 4-drawArea (Drawing  Area widget) child of scroll window
  23.  
  24. Here are what I want it to behave:
  25. 1)When user click on the drawing area, the drawing are should have
  26.     keyboard focus.
  27. 2)If the draw area has keyboard focus AND user types any key 
  28.     except up, down, left and right arrow keys, 
  29.     the keyboard focus should transfer to the entry window.
  30. 3)If the entry window has keyboard focus AND user hits an ENTER
  31.     key, the keyboard focus should transfer to the draw area.
  32.  
  33. I use XmProcessTraversal to transfer keyboard focus from draw area
  34. to entry window and it works.
  35. Yet, when I want to transfer the keyboard focus from entry window to
  36. draw area, it DOES NOT.
  37. Why?
  38. I've noticed in the CoreClassPart structure there's field for
  39. AcceptFocusProc
  40. Currently it's being set to NULL. What's this field for anyway?
  41.  
  42. Thanks
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65. Additional info:
  66. ---------
  67. Machine: RS6000
  68. OS: AIX 32
  69. Motif: 1.1
  70. Compiler: cc
  71.  
  72. -----------
  73. XNewClassRec XnewClassRec =
  74. {
  75.   {
  76.     /* CoreClassPart */
  77.     (WidgetClass) &widgetClassRec,  /* superclass            */
  78.     "Command",                        /* class_name            */
  79.     sizeof(XNewRec),           /* widget_size           */
  80.     NULL,                           /* class_initialize      */
  81.     NULL,                           /* class_part_initialize */
  82.     FALSE,                          /* class_inited          */
  83.     Initialize,                     /* initialize            */
  84.     NULL,                           /* initialize_hook       */
  85.     Realize,                        /* realize               */
  86.     action_list,                    /* actions               */
  87.     XtNumber( action_list ),        /* num_actions           */
  88.     cmd_resources,                /* resources             */
  89.     XtNumber( cmd_resources ),    /* num_resources         */
  90.     NULLQUARK,                      /* xrm_class             */
  91.     TRUE,                           /* compress_motion       */
  92.     TRUE,                           /* compress_exposure     */
  93.     TRUE,                           /* compress_enterleave   */
  94.     TRUE,                           /* visible_interest      */
  95.     Destroy,                        /* destroy               */
  96.     WindowResize,                   /* resize                */
  97.     Redisplay,                      /* expose                */
  98.     SetValues,                      /* set_values            */
  99.     NULL,                           /* set_values_hook       */
  100.     XtInheritSetValuesAlmost,       /* set_values_almost     */
  101.     NULL,                           /* get_values_hook       */
  102.     NULL                            /* accept_focus          */
  103.     XtVersion,                      /* version               */
  104.     NULL,                           /* callback private      */
  105.     default_translations,           /* tm_table              */
  106.     NULL,                           /* query_geometry        */
  107.     NULL,                           /* display_accelerator   */
  108.     NULL,                           /* extension             */
  109.   },
  110.   {
  111.     /*Command Widget ClassPart */
  112.     0,                              /* ignore                */
  113.   }
  114. };
  115.  
  116. -----------
  117. static void Initialize( XNewWidget request, XNewWidget new )
  118. {
  119. ..
  120.   n = 0;
  121.   Foundation = XtCreateManagedWidget( "Foundation", xmFormWidgetClass, XtParent( new ), args, n );
  122.  
  123.   n = 0;
  124. ..
  125.   EntryWindow = XtCreateManagedWidget( "EntryWindow", xmTextWidgetClass, Foundation, args, n );
  126.   XtAddCallback( EntryWindow, XmNactivateCallback, EnterHit, new );
  127.  
  128.   n = 0;
  129. ..
  130.   ScrolledWindow = XmCreateScrolledWindow( Foundation, \string{"ScrolledWindow", args, n );
  131.  
  132.   n = 0;
  133.   DrawArea = XtCreateWidget( "DrawArea", xmDrawingAreaWidgetClass, ScrolledWindow, args, n );
  134.   XmAddTabGroup( DrawArea );
  135.  
  136.   XtAddEventHandler( DrawArea, ButtonPressMask, FALSE, ButtonPressed, new );
  137.  
  138.   n = 0;
  139.   XtSetArg( args[n], XmNworkWindow,DrawArea ); ++n;
  140.   XtSetValues( ScrolledWindow, args, n );
  141.  
  142.   XtManageChild( DrawArea );
  143.   XtManageChild( ScrolledWindow );
  144. }
  145.  
  146. -----------
  147. static XtActionsRec action_list[] =
  148. {
  149.   {"KeyUp", KeyUp},
  150.   {"KeyDown", KeyDown},
  151.   {"KeyLeft", KeyLeft},
  152.   {"KeyRight", KeyRight},
  153.   {"KeyOther", KeyOther},
  154. };
  155.  
  156. static char default_translations[] =
  157. "     <Key>osfUp : KeyUp()\n\
  158.       <Key>osfDown : KeyDown()\n\
  159.       <Key>osfLeft : KeyLeft()\n\
  160.       <Key>osfRight : KeyRight()\n\
  161.       <Key> : KeyOther()";
  162. -------------
  163.  
  164. static void KeyOther( XNewWidget w, XEvent * event, char * parm[], int i )
  165. {
  166.       XmProcessTraversal( EntryWindow, XmTRAVERSE_CURRENT );
  167. }
  168. -------------
  169.  
  170. static EnterHit( Widget w, XNewWidget new, XmAnyCallbackStruct * call_data )
  171. {
  172.       XmProcessTraversal(DrawArea, XmTRAVERSE_CURRENT );
  173. }
  174. ---
  175. Dan Dao dao@rchland.vnet.ibm.com (507)253-8023
  176.