[comp.windows.x.motif] Using the return key for traversal?

stuart@siesoft.co.uk (Stuart Hood) (02/12/91)

Hardware: Siemens WX200.
Software: SCO Development Kit (Motif 1.0, X11 release 3).

I have a main window with two child, text widgets.  The main window
is a tab group so that the user may use the cursor up and down keys
to navigate between the two text objects.

I would like somehow to have the return key behave like the cursor
down key, i.e. if the user hits return then it navigates to the
next text object as if they had pressed the cursor down key.

I could add an activate callback to each widget and then navigate
to the desired widget using _XmGrabTheFocus() but this seems a
little messy.  I would be happier using XmProcessTraversal but
I do not have Motif 1.1.

I would be grateful to anyone who can come up with a cleaner method
of doing this.

Stuart.
-
--
S I E M E N S  Stuart Hood 65-73 Crockhamwell Road, Woodley, Berkshire, UK
-------------  Phone: + 44-734-691994          Email: stuart@siesoft.co.uk
N I X D O R F  The trouble with everyone, is that they generalise too much

manny@se-sd.SanDiego.NCR.COM (Manny Bagnas) (02/13/91)

In article <1991Feb12.113638.5936@siesoft.co.uk> stuart@siesoft.co.uk (Stuart Hood) writes:

>I have a main window with two child, text widgets.  The main window
>is a tab group so that the user may use the cursor up and down keys
>to navigate between the two text objects.
>
>I would like somehow to have the return key behave like the cursor
>down key, i.e. if the user hits return then it navigates to the
>next text object as if they had pressed the cursor down key.

How about this:

Modify translations for the text widget.  This can be done through the
X resource mechanism (i.e. an app-defaults file for your application), or
or modify translations in the source.

A simple app-defaults file would look like this:

Your-App-Class*XmText*translations:	#override <Key>Return:  traverse-next()

If you had other text widgets in your application which require
a different behavior, then you'd need to modify the above resource to use 
the text widget names rather than class.

Works for me...

Manny

pjp@sloth.mlb.semi.harris.com (Pat J. Pinchera) (05/08/91)

In article <1991Feb12.113638.5936@siesoft.co.uk> stuart@siesoft.co.uk (Stuart Hood) writes:
>Hardware: Siemens WX200.
>Software: SCO Development Kit (Motif 1.0, X11 release 3).
>
>I have a main window with two child, text widgets.  The main window
>is a tab group so that the user may use the cursor up and down keys
>to navigate between the two text objects.
>
>I would like somehow to have the return key behave like the cursor
>down key, i.e. if the user hits return then it navigates to the
>next text object as if they had pressed the cursor down key.
>
>I could add an activate callback to each widget and then navigate
>to the desired widget using _XmGrabTheFocus() but this seems a
>little messy.  I would be happier using XmProcessTraversal but
>I do not have Motif 1.1.
>
>I would be grateful to anyone who can come up with a cleaner method
>of doing this.
>
>Stuart.

I just posted an answer to another person asking a similar question. At
the risk of wasting a little bandwidth, here's the solution I
implemented with 1.0 (credit goes to some kind soul on the net who
responded to my request several months ago).

	I had to add the widget(s) to a tab group so that a regular
<Tab> would make the cursor move between the text fields. Than had to
make the <Return>, and 'down-arrow' look like a <Tab> to Motif; this 
is done with XtOverrideTranslations.

Here is a code excerpt:

        /*
	** make the text widgets part of a 'Tab Group' so that user
	** can tab between text fields. See PG9-3, PG1-6, PR1-163
	** PG = Motif Programmer's Guide, v1.0, 
	** PR = Motif Programmer's Reference, v1.0
	*/
	XmAddTabGroup ( widget );
						       
        /*
        ** make <Return>, Down-Arrow act like a Tab;
        ** make Up-Arrow act like a Shift-Tab (back tab)
        */
        XtOverrideTranslations(widget, XtParseTranslationTable
                                    ("<Key>Return:next-tab-group()\n\
                                      <Key>Down:next-tab-group()  \n\
                                      <Key>Up:prev-tab-group()"));


-- 
---------------------------------------------------------------------
  Patrick J. Pinchera            |  Interface & Control Systems, Inc.
  pjp@sloth.mlb.semi.harris.com  |  Melbourne, Florida, USA
---------------------------------------------------------------------