[comp.windows.x.motif] Problem with XmProcessTraversal

chuck@Morgan.COM (Chuck Ocheret) (10/30/90)

I am doing something weird in a widget which I wrote which works in
Motif 1.0 and am looking for suggestions to solve my problem properly
with 1.1.

The widget in question is a subclass of Manager and contains the
following default children as depicted below.  The DrawingArea
represents something like a spreadsheet in that rows and columns of
data are displayed.

        +--------------------------------------------------------+
        |                       Label 1                          |
        +--------------------------------------------------------+
        |                       Label 2                          |
        +----------+----------+----------+----------+----------+-+
        | Button 1 | Button 2 | Button 3 | Button 4 | Button 5 | |
        +----------+----------+----------+----------+----------+-+
        | row1col1   row1col2   ...................   row1col5 |^|
        | row2col1                                             |-|
        |                                                .     | |
        |    .                                           .     |s|
        |    .             DrawingArea                   .     |c|
        |    .                                           .     |r|
        |    .                                           .     |o|
        |    .                +----------+               .     |l|
        |    .                |   Text   |               .     |l|
        |    .                +----------+               .     |b|
        |    .                                           .     |a|
        |    .                                           .     |r|
        |    .                                           .     | |
        |                                                      |-|
        | rowNcol1   rowNcol2   ...................   rowNcol5 |v|
        +------------------------------------------------------+-+
        |<|                      scrollbar                   |>| |
        +------------------------------------------------------+-+

In order to allow data entry I create a Text widget (I will probably
use a TextField in 1.1) as a child of the DrawingArea (every other
widget depicted is a child of my new widget).  The Text widget is
created and managed with mappedWhenManaged set to FALSE.  I add a
keyboard translation to the DrawingArea such that the Text widget is
configured over the appropriate cell and then mapped when the user
starts to type in data.

At this point, I want the Text widget to take over and provide all of
its useful capabilities.  This requires that the Text widget get focus
when it is mapped.  With Motif 1.0 I was able to kludge this with
XtSetKeyboardFocus (I have been told that this was always a bad idea
with Motif).  Now I am trying to use XmProcessTraversal but am having
no luck getting focus on the Text widget.  XmProcessTraversal always
returns FALSE.  Upon examination with dbx I see that in
_XmMgrTraversal() both _XmGetTabGroup and _XmFindTabGroup return NULL
pointers because the focusData in the applicationShell doesn't
indicate a current tab group.

It would also be nice if the user could tab to the buttons, the
scrollbars, and the drawing area.

I need suggestions as to how to do this kind of thing properly.  I
would also really appreciate it if someone out there who really
understands the Motif traversal mechanism could post to this group a
summary about how it works, especially from the perspective of widget
writers.  I've written a bunch of Motif-subclassed widgets so far
and almost always run into problems with traversal.

~chuck

-- 
+--------------------+   Chuck Ocheret, Sr. Staff Engineer   +---------------+
|chuck@APT.Morgan.COM|       Morgan Stanley & Co., Inc.      |(212) 703-4474 |
|    Duty now ...    |19th Floor, 1251 Avenue of the Americas|for the future.|
+--------------------+      New York, N.Y.  10020 USA        +---------------+