Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!sun-barr!newstop!sun!argv From: argv@turnpike.Eng.Sun.COM (Dan Heller) Newsgroups: comp.windows.x.motif Subject: Re: Keyboard input in multiple text widgets Message-ID: <141184@sun.Eng.Sun.COM> Date: 23 Aug 90 00:14:51 GMT References: <6597@milton.u.washington.edu> Sender: news@sun.Eng.Sun.COM Organization: O'Reilly && Associates Lines: 44 In article <6597@milton.u.washington.edu> subaru@milton.u.washington.edu (Steve Chen) writes: > > I have set up a pop-up window like below: > +--------------------------------------------------+ > | +------------------------+ | > | User Name: | Text Widget 1 | | > | +------------------------+ | > | +------------------------+ | > | Password: | Text Widget 2 | | > | +------------------------+ | > +--------------------------------------------------+ Reader wants Return to toggle between the two items.... (I assume these text widgets are simple-line editing widgets...) Set up a callback for your text widgets: XtAddCallback(textw1, XmNactivateCallback, next_item, textw2); XtAddCallback(textw2, XmNactivateCallback, next_item, textw1); The function next_item() looks like: void next_item(w, client_data) Widget w, client_data; { XSetInputFocus(XtDisplay(client_data), XtWindow(client_data), RevertToParent, CurrentTime); } In your simple example, however, you could just add the two text widgets to a tab group: XmAddTabGroup(textw1); XmAddTabGroup(textw2); Then, TAB will take you back and forth -- you could even add a translation table that makes Return go to the next tab group. But my first solution above will work in more general cases because it doesn't make any assumptions about the tab group and how many other items might be in those groups. -- dan ---------------------------------------------------- O'Reilly && Associates argv@sun.com / argv@ora.com Opinions expressed reflect those of the author only.