From: lmdrsm@ludvig.ericsson.se (Roar Smith)
Subject: Re: CARET ITEM
Reply-To: lmdrsm@ludvig.ericsson.se
Organization: L.M. Ericsson A/S
Date: Thu, 13 Aug 1992 12:35:29 GMT

In article l8cu0hINNhet@cronkite, billh@mugwump.UK.Sun.COM (Bill Hodgson - Sun EHQ - Cascade) writes:
>Dear All, (but I expect Tank to answer)
>
>I have a window with 2 panels and two textfields:
>
>|===============================================|
>|						|
>|	TF A: ___________			|
>|						|
>|						|
>|						|
>|===============================================|
>|						|
>|						|
>|	TF B: ___________			|
>|						|
>|						|
>|===============================================|
>
>I want the TAB key to move the focus between the two textfields, XView doesn't do this
>normally, but keeps the tabbing in scope of the control panel.  
>
>I tried using PANEL_CARET_ITEM but it core dumps when I specify the other panel in
>the TF's event proc.
>
>Anyone got any answers please?  
>

I'm sorry, but I didn't read this article before today (August 13th).

I've had a similar problem, where I wanted to move the input focus from a panel
text field to a textsw.

For you the solution migth be something like this:

/* Starting sample program text */
Panel		panel_A,		panel_B;
Panel_item	panel_A_text,		panel_B_text;
Panel_setting	panel_A_text_proc(),	panel_B_text_proc();

main()	/* Or whatever */
{
	.
	.
	.
	panel_A =	(Panel)xv_create(...
	panel_A_text =	(Panel_item)xv_create(panel_A, ...
	panel_B =	(Panel)xv_create(...
	panel_B_text =	(Panel_item)xv_create(panel_B, ...
	.
	.
	.
	/* Install notify procedure for text field in panel A */
	/* It is assumed that you only want to catch a TAB character */
	xv_set(panel_A_text,
		PANEL_NOTIFY_LEVEL,		PANEL_SPECIFIED,
		PANEL_NOTIFY_STRING,		"\t",
		PANEL_NOTIFY_PROC,		panel_A_text_proc,
		NULL);

	/* Install notify procedure for text field in panel B */
	/* It is assumed that you only want to catch a TAB character */
	xv_set(panel_B_text,
		PANEL_NOTIFY_LEVEL,		PANEL_SPECIFIED,
		PANEL_NOTIFY_STRING,		"\t",
		PANEL_NOTIFY_PROC,		panel_B_text_proc,
		NULL);
	.
	.
	.
}

Panel_setting
panel_A_text_proc(item, event)
Panel_item	item;
Event		*event;
{
	Xv_Window	text_window;
	int		xid;
	
	switch( event_action(event) ) {
	case '\t':
		text_window = (Xv_Window)xv_get(panel_B,
			 OPENWIN_NTH_VIEW, 0);
		xid = (int)xv_get(text_window, XV_XID);
		win_set_kbd_focus(text_window, xid);
		return (PANEL_NONE);
		break;
	default:
		return panel_text_notify(item, event);
	}
}

Panel_setting
panel_B_text_proc(item, event)
Panel_item	item;
Event		*event;
{
	Xv_Window	text_window;
	int		xid;
	
	switch( event_action(event) ) {
	case '\t':
		text_window = (Xv_Window)xv_get(panel_A,
			 OPENWIN_NTH_VIEW, 0);
		xid = (int)xv_get(text_window, XV_XID);
		win_set_kbd_focus(text_window, xid);
		return (PANEL_NONE);
		break;
	default:
		return panel_text_notify(item, event);
	}
}

/* Ending sample program text */

Hopefully this can solve your little problem.

(Flame protection: This specific code hasn't been tested, only some similar code !!!)

           ######  Roar Smith, M.Sc.EE.         ***  Organization:
          #        Coordination, UNIX Network   ***  L.M. Ericsson A/S
UNIX     #         Phone: +45 3388 3577         ***  Sluseholmen 8
    #   #          FAX:   +45 3388 3134         ***  DK-1790 Kobenhavn V
     # #           MEMO:  LMD.LMDRSM            ***  Denmark
      #            Email: lmdrsm@ludvig.ericsson.se 
+---------------------------------------------------------------------+
!   Double-click  (HERE)  and you might already have won $5,000,000   !
+---------------------------------------------------------------------+

Xref: sparky alt.toolkits.xview:787 comp.windows.open-look:3551 comp.windows.x:15504