[comp.windows.x.motif] Help required with text widget

jeremy@EIK.II.UIB.NO (08/16/90)

 
Were trying to get an application which uses a Text widget to 
honour the 'XmNcursorPosition' resource. The problem seems to be
that the widget will not display the cursor at all until the user
has clicked M1 in the window. If anyone can throw any light on how
to get the blinking cursor to show without having to point and click
we'd be very grateful.


-------------------------------------------------------------------------------
 Jeremy Cook                      .----.
 Parallel Processing Laboratory  /    /                      /  /        /
 University of Bergen           /    /                      /  /        /
 Thormoehlensgate 55           /----' .----. .----. .----. /  / .----. /----.
 N-5008 Bergen                /      _____/ /      _____/ /  / _____/ /    / 
 Norway                      /      (____/ /      (____/ /  / (____/ (____/
-------------------------------------------------------------------------------
 email : jeremy@eik.ii.uib.no    | "My other computer is a MasPar MP1208"
 phone : +47 5 54 41 74 (direct) |
 fax   : +47 5 54 41 99          |
-------------------------------------------------------------------------------

vanharen@MIT.EDU (Chris VanHaren) (08/16/90)

>> Were trying to get an application which uses a Text widget to 
>> honour the 'XmNcursorPosition' resource. The problem seems to be
>> that the widget will not display the cursor at all until the user
>> has clicked M1 in the window. If anyone can throw any light on how
>> to get the blinking cursor to show without having to point and click
>> we'd be very grateful.

I've used XtSetKeyboardFocus to do this.  I don't know if this is the
OSF approved method, but it works for me.  Just add:

	XtSetKeyboardFocus(subtree, text_widget);

to your code, where 'text_widget' is your text widget, and 'subtree' is
the subtree of widgets in your application, that, when you enter it,
keyboard focus will be directed to that text widget.  So, you may want
to just use your toplevel, if your application has only one window, or,
if your text widget is in a dialog or something, use the dialog shell
as the root of the subtree.

The problem that I have been having, though, is that sometimes when a
widget loses focus, it doesn't un-highlight.  The blinking cursor stays
on, or in a list widget, the highlight rectangle doesn't go away.  I
don't think this is the fault of XtSetKeyboardFocus, though, but a
problem in the widgets, since it happens to me sometimes even when I
don't use XtSetKeyboardFocus.  If anyone else knows how to correct this
problem, please let me know.
						-Chris.