[comp.sys.next] Setting a PopUpList's selection

jacob@gore.com (Jacob Gore) (07/01/89)

Given an instance of PopUpList, how do you select, from the program, an
item in it?

The only ways I can think of doing this are all yucky.

One way is capture the 'sender' of the first click as the Matrix instance
that the PopUpList is using, and then do something like 
	[theMatrix selectCellAt:itemNumber:0]
(uhm... that's assuming that pop-up list's are represented vertically in the
matrix... are they?).  But this only works after a click on the list.  Yuck.

Another way, possibly, is to play with pop-up lists until I can figure out
a way to insert things that ends up with the right thing selected (effect
of inserting or adding items on the selected item is not documented in the
PopUpList class description).  Double yuck, and probably futile anyway.


I am trying to have an int instance variable that stores the current
selection in a corresponding pop-up list.  I need that variable to change
when the list's selected item changes (easy enough), and vice versa.


Is there a particular reason why there is no setSelectedItem: (or
selectItem:) instance method in PopUpList?

Jacob
--
Jacob Gore	Jacob@Gore.Com		{nucsrl,boulder}!gore!jacob

jacob@gore.com (Jacob Gore) (07/08/89)

/ comp.sys.next / jacob@gore.com (Jacob Gore) / Jun 30, 1989 /
> Given an instance of PopUpList, how do you select, from the program, an
> item in it?
> ...
> One way is capture the 'sender' of the first click as the Matrix instance
> that the PopUpList is using, and then do something like 
> 	[theMatrix selectCellAt:itemNumber:0]

Duh... get used to RTFM all they way up the inheritance chain, Jacob...

Anyway, in case anybody else is waiting for the answer:

	PopUpList inherits from Matrix method 'itemList', which returns
	the matrix.  So, what I was looking for was:

		[[thePopUpList itemList] selectCellAt:itemNumber:0]

Now, if I could only figure out why doing the selectCellAt:: has no effect
on the appearance of the pop-up list...

--
Jacob Gore	Jacob@Gore.Com		{nucsrl,boulder}!gore!jacob

rokicki@polya.Stanford.EDU (Tomas G. Rokicki) (07/09/89)

In article <130011@gore.com>, jacob@gore.com (Jacob Gore) writes:
> Now, if I could only figure out why doing the selectCellAt:: has no effect
> on the appearance of the pop-up list...

I believe you also need to set the title of the button if you are doing
the selection yourself . . . 

-tom