Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!sun-barr!newstop!exodus!argv From: argv@turnpike.Eng.Sun.COM (Dan Heller) Newsgroups: comp.windows.x.motif Subject: Re: Help wanted with focus policy. Keywords: Help, Focus Policy, Text widgets Message-ID: <3323@exodus.Eng.Sun.COM> Date: 22 Nov 90 17:59:35 GMT References: <1990Nov21.154611.25895@siesoft.co.uk> Sender: news@exodus.Eng.Sun.COM Distribution: comp Organization: O'Reilly && Associates Lines: 49 In article <1990Nov21.154611.25895@siesoft.co.uk> stuart@siesoft.co.uk writes: > In the simplest case, I have a window with a single text widget. > I want to be able to do just two things: > > 1) start editing the text widget from my application, i.e. without the > user having to click on the text widget. > > 2) stop editing the text widget, i.e. lose the focus, without the user > having to click on another text widget (there isn't another one :-) > > Dan Heller suggested using XSetInputFocus (surprise, surprise :-) to > solve a similar problem with two widgets. I recommended that at the time because I only had 1.0 (as you do) and I was unaware of the damaging side effects of using the function (and the sister function, XtSetInputFocus()) because Motif isn't expecting that kind of stuff. Doing this sort of thing will break a few things internally to motif, but the side effects may not be noticable right away. One problem is that the blinking cursor is done using a timeout routine (XtAddTimeOut()) and motif isn't pro- perly resetting that when you change focus using X[t]SetInputFocus(). The workaround for this is to set the blink rate resource to 0. I think there are other problems as well, but I don't remember exactly what they are. If you are going to use 1.1 anytime in the near future, I recommend defering the problem till then and using Gabe's suggestion: > > { > XtAddCallback(window, XmNinputCallback, MouseClick, NULL); > ... > } > void MouseClick(Widget w, char *dummy, XmAnyCallbackStruct *datap) > { > XmProcessTraversal(text_w, XmPROCESS_CURRENT); > } I might note that a "red flag" goes up in my mind when I see people trying to munge the focus policy of their applications. We revisit the issue of "compatiblity", not just with Motif, but with other applications. If everyone does this sort of thing, the users who get Motif apps from different vendors may not be able to do the same things and get the same results across all apps.. Of course, I don't know your particular situation, but it's something to think about. -- dan ---------------------------------------------------- O'Reilly && Associates argv@sun.com / argv@ora.com Opinions expressed reflect those of the author only.