subaru@milton.u.washington.edu (Steve Chen) (08/22/90)
I have set up a pop-up window like below: +--------------------------------------------------+ | +------------------------+ | | User Name: | Text Widget 1 | | | +------------------------+ | | +------------------------+ | | Password: | Text Widget 2 | | | +------------------------+ | +--------------------------------------------------+ What I want to do is to let the user enter his/her user name and password. When a <return> is typed in the Text Widget1, the pointer will warp to Text Widget2 and any keyboard input in Text Widget2 is retained but output onto TextWidget2 as some special character e.g. "*" My problem is, how do I check for each keyboard input and how do I warp the pointer from TextWidget1 to TextWidget2. I would appreciate it very much if someone could help me out on this. steve steve@gohma.ee.washington.edu
argv@turnpike.Eng.Sun.COM (Dan Heller) (08/23/90)
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.