[comp.windows.open-look] Guide & Scrolling Lists

jack@richsun.cpg.trs.reuter.com (Jack Gidding) (05/24/91)

Hello!

I created a scrolling list in one of my recent developments, and I accidentally
made it editable. I initially thought that this was a tragic incident, but I
finally came to the conclusion that this is what I want to happen. Can someone
tell me though, how a program can know that someone has inserted/deleted an
object(or two)?

The O'Reilly Book Vol 7 has only a little bit about scrolling lists in it.


advTHANKSance


 _____________________________________________________________________
$ Jack A. Gidding			  $ "Sadly for the egos of    $
$ Development Engineer			  $  engineers, much of what  $
$ 		     			  $  we hold dear does not    $
$ Reuters Trading Room Systems		  $  have critical market     $
$ 1400 Kensington Road			  $  impact, because it's     $
$ Oak Brook, IL 60521			  $  drowned out by factors   $	
$ 					  $  that are more important  $
$ Voice: (708) 574-7424 x2770       	  $  to customers."	      $
$ Email: jack@richsun.cpg.trs.reuter.com  $       -Dan Weinreb	      $
 ---------------------------------------------------------------------

brentb@montagne.Eng.Sun.COM (Brent Browning) (05/28/91)

In article <1867@richsun.cpg.trs.reuter.com> jack@richsun.cpg.trs.reuter.com (Jack Gidding) writes:
>
>I created a scrolling list in one of my recent developments, and I accidentally
>made it editable. I initially thought that this was a tragic incident, but I
>finally came to the conclusion that this is what I want to happen. Can someone
>tell me though, how a program can know that someone has inserted/deleted an
>object(or two)?

   This is a fairly hidden feature of OPEN LOOK.  If you make a 
scrolling list editable it will have a different floating menu.
One of the items on the menu is "Edit List".  When you choose
this item nothing seems to happen at first.  If you bring up the
menu again you will see more choices, including "Change", "Insert",
and so on.  Once you are done you need to choose "End Editing".

   It's pretty handy, but it so hidden that most people tend to put
an "Edit" button and a text field below the list...  At any rate,
this is supported in XView through the scrolling lists notify proc.

   There are four cases to handle, select/deselect, validate, and
delete.  The latter two are the pertinent ones here.  A scrolling
list notify proc has an int return value.  Your notify proc 
will be called with PANEL_LIST_OP_VALIDATE each time a new
item is added to the list by the user.  If you return XV_OK
then the item is inserted into the list.  If you return XV_ERROR
then the change is rejected.  Here's a sample:

int
list_proc(item, string, client_data, op, event)
	Panel_item	item;
	char		*string;
	Xv_opaque	client_data;
	Panel_list_op	op;
	Event		*event;
{
	switch(op) {
	case PANEL_LIST_OP_DESELECT:
		break;
	case PANEL_LIST_OP_SELECT:
		break;
	case PANEL_LIST_OP_VALIDATE:
		if (item_is_valid)
			return XV_OK;
		else
			return XV_ERROR;
		break;
	case PANEL_LIST_OP_DELETE:
		break;
	}
	
	return XV_OK;
}

   I'm at home without my O'Reilly book so please forgive any typos
or minor mistakes.

--
Brent Browning			Internet: brentb@Eng.Sun.COM
Sun Microsystems, Inc		UUCP: ...!sun!brentb
2550 Garcia Ave. MTV 01-40	Phone: (415) 336-5573
Mountain View, CA 94043