[comp.sys.next] Accessing/updating PopUpLists

jkight@sinai.umd.edu (Jeff Kight) (01/23/91)

I think I may be too involved in this problem to see the solution...

I am programming under 2.0 with the Interface Builder. I add a PopUpList
which is a combination button/popuplist.

The technical docs say: Accessing the PopUpList's Button is useful if you
want to change the title displayed for the list.  To access the Button from
your code, give it a tag in the Interface Builder's Inspector.  Send a
setTitle: message to the Button to change the title string it displays.  If
the title you send isn't represented in the PopUpList, it's added at the top
of the list the next time the user manipulates the Button.

When I repeatedly add titles to the button, it only "adds" the last one, as
it should by the above definition. If I setTitle then click the button (pop
up the list) and then perform another setTitle, the different titles are
added.

So, I tried performClick's after setTitle's...no go.

I try to send PopUpList methods to the button: method not defined.

I try to form a connection to the PopUpList: can't find a way.

If anyone would have an idea/solution, I would much appreciate it.

------------------------------------------------------------------------------
Jeff Kight                                                 jkight@umd5.umd.edu
Information Services                                        jkight@umdd.bitnet
Computer Science Center                              uunet!umd5.umd.edu!jkight
University of Maryland                                          (301) 405-3014

glenn@heaven.woodside.ca.us (Glenn Reid) (01/23/91)

In article <7885@umd5.umd.edu> jkight@sinai.umd.edu (Jeff Kight) writes:
>I am programming under 2.0 with the Interface Builder. I add a PopUpList
>which is a combination button/popuplist.

[ some stuff deleted about using "setTitle:" ]

>When I repeatedly add titles to the button, it only "adds" the last one, as
>it should by the above definition. If I setTitle then click the button (pop
>up the list) and then perform another setTitle, the different titles are
>added.

Try this method instead, if you want to add a whole bunch of items to the
popup list before you start using it (this is from the tech docs under
PopUpList):

    - addItem:(const char *)title

    Adds the item with the name title to the PopUpList.  The newly
    added cell is returned.  The new item is added to the end of the list.

/Glenn
-- 
 Glenn Reid				RightBrain Software
 glenn@heaven.woodside.ca.us		NeXT/PostScript developers
 ..{adobe,next}!heaven!glenn		415-851-1785 (fax 851-1470)

adonis1@nwnexus.WA.COM (Adonis Corporation ) (01/23/91)

In article <7885@umd5.umd.edu> jkight@sinai.umd.edu (Jeff Kight) writes:
>
>
>The technical docs say: Accessing the PopUpList's Button is useful if you
>want to change the title displayed for the list.  To access the Button from
>your code, give it a tag in the Interface Builder's Inspector.  Send a
>setTitle: message to the Button to change the title string it displays.  If
>the title you send isn't represented in the PopUpList, it's added at the top
>of the list the next time the user manipulates the Button.
>
>When I repeatedly add titles to the button, it only "adds" the last one, as
>it should by the above definition. If I setTitle then click the button (pop
>up the list) and then perform another setTitle, the different titles are
>added.
>
>So, I tried performClick's after setTitle's...no go.
>
>I try to send PopUpList methods to the button: method not defined.
>
>I try to form a connection to the PopUpList: can't find a way.


I'm no expert on this, but I believe you can gain access to the popup
via the target of the button: 
	buttonTarget = [myButton target]. 
That'll get you into the PopUpList.  But for some things you need to go a
little deeper and get the id of the matrix which is responsible for
displaying the list of items in your PopUpList: 
	popupMatrix = [aPopUp itemList].
This is how I think things worked in 1.0 when you had to build your
own PopUpLists from scratch. My limited experience so far with 2.0
is that the model still holds. 

In 1.0 you were not supposed to set the target
of the button to the PopUpList in Interface Builder for some reason,
and I presume that still holds, but now IB does it for you, so who cares.
I wonder though what would happen if you did set the target of the button to 
something else?


-Doug Kent
Independent NeXT Developer

adonis1@nwnexus.WA.COM (Adonis Corporation ) (01/23/91)

Ooops.. I made a typo in my response to this query about PopUpLists.

Unfortunately I don't have access to my posting, so I can't quote myself
exactly.  I gave two example lines of code.  The first one assigned
a value to a variable named something like "myButtonTarget".  That
variable should've been named "aPopUp".

Sorry for the confusion.

-Doug Kent
Independent Next Developer

scott@mephistopheles.gac.edu (Scott Hess) (01/24/91)

In article <460@nwnexus.WA.COM> adonis1@nwnexus.WA.COM (Adonis Corporation ) writes:
  In 1.0 you were not supposed to set the target
  of the button to the PopUpList in Interface Builder for some reason,
  and I presume that still holds, but now IB does it for you, so who cares.
  I wonder though what would happen if you did set the target of the button to 
  something else?

The PopUpList part of a popup list is actually a subclass of Menu.  When
you click the button, a message is sent to the target which essentially
tells it to popup.  If you changed the target, or messed with too much
of the button, it wouldn't work anymore (actually, it'd work like a
normal button).

The real target to be concerned with is the target of either the Matrix
within the popup, or the target of a cell within that matrix, because
that determines who gets called with what when you use a popup.
--
scott hess                      scott@gac.edu
Independent NeXT Developer	GAC Undergrad
<I still speak for nobody>
"Tried anarchy, once.  Found it had too many constraints . . ."
"Buy `Sweat 'n wit '2 Live Crew'`, a new weight loss program by
Richard Simmons . . ."