[comp.windows.x.motif] Strange TextWidget focus behaviour

f28982j@kaira.hut.fi (Karl R J Holmstrom) (11/08/90)

This has probably been asked before, but could somebody please help
me.

I have difficulties in getting a TextWidget to give up focus.  I have
one single line TextWidget in a FormWidget along with a few
PushButtonWidgets and a DrawingArea.

I would like the TextWidget to behave like this:

   When I click on the TextWidget, it should get keyboard focus.  When
   I press return or click on the surrounding form, the TextWidget
   should lose focus so that I can update the application with the new
   string.

The TextWidget gets the focus but I can't figure out how to loose
focus.  I've tried to add a translation to the surrounding FormWidget
that calls _XmGrabTheFocus or XSetInputFocus after a button press.
However, nothing seems to affect the TextWidget focus.  When it has
once obtained focus there seems to be no way to give up focus!

I'm using Motif 1.0.X on HP-UX 7.0.

Karl

nmm@cl.cam.ac.uk (Nick Maclaren) (11/09/90)

nazgul@alphalpha.com (Kee Hinckley) writes:
> Focusin/out is a real tempting way to update from a text widget,
> but it's wrong.  ....

That is untrue, I am afraid.  The word should be 'unsupported'.  I have
an application where it is the RIGHT thing to do, even though I cannot
do it reliably in Motif (for the reasons that Kee states).  In fact, I
believe (from experience with the HP widgets) that the fundamental
restrictions are partially in the X Toolkit itself.

I quite agree that it is incompatible with a pointer focus environment,
but that is another point.  In the application mentioned above, I would
like to use selection focus policy within my own windows, but leave
external focus policy to the window manager.  Ho, hum!

Nick Maclaren
University of Cambridge Computer Laboratory
nmm@cl.cam.ac.uk