🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.next.programmer
4 messages
4 total messages Started by Gregory H. Anderson Wed, 12 Aug 1992 00:23
Getting a PopUpList's window
#544
Author: Gregory H. Anderson
Date: Wed, 12 Aug 1992 00:23
83 lines
3624 bytes
Someone sent me this by email to our free support line, but there was no  
sender anywhere to be found on the mail. It was even blank in my mailbox.  
(Probably a PR2 beta tester with a munged sendmail...  8^)) Anyway, I hope  
you recognize yourself and find the answer here. Let me know who you are,  
so I can record it in our files.

The question was:
-------------------------------------------------------------------------
I have several (5) Windows, each with a fairly large number of data entry  
items - Switches, TextFieldCells, and PopUpLists - and a generic  
home-grown object - ChangeController. ChangeController is the target  
object of the Switches, TextFieldCells and PopUpLists with an action of  
controlDidChange:sender.

All controlDidChange: wants to do is "dirty" the appropriate Window with  
setDocEdited:YES. For the Switches and TextFieldCells, I simply
	[[sender window] setDocEdited:YES];

But I cannot determine the Window in which the PopUpLists are. I have sent  
messages to the Matrix (sender) and the selectedCell. They seem to think  
they are in a PopUpList window, but how can I determine which window the  
PopUpList is in?
-------------------------------------------------------------------------

The answer is:

You are doing an inherently problematic thing, because PopUpLists are NOT  
controls, like TextFields and Buttons. They inherit through the Window  
hierarchy and are actually subclasses of Menus. By definition, you cannot  
ask a Window what Window it lives on. The Matrix lives on the PopUpList,  
not the Window it appears to be on, so it's no help either. Even the cover  
button is no help, because it's not directly attached to the PopUp.

The only way to figure out which effective Window sent the message is to  
subclass PopUpList, create an instance variable to store the effective  
window, and override the popUp: method. Try this:

@interface MyPopUpList:PopUpList 
	{
	id effectiveWindow;
	}

- effectiveWindow;

@end

@implementation MyPopUpList

- popUp:sender
	{
	effectiveWindow = [sender window];
	return [super popUp:sender];
	}

- effectiveWindow { return effectiveWindow; }

@end

In your case, it should be safe to assume that the sender is the button  
covering the PopUpList, so [sender window] should be what you're looking  
for. Now, in your controller code, say:

- receivePopUpMessage:sender
	{
	[[[sender window] effectiveWindow] setEdited:YES];
	}

There is no way to notify the target in advance (like at the top of the  
popUp: override), because the actions of individual cells in a PopUpList  
can all point to different targets. You wouldn't know who to send the  
message to until a specific cell is chosen. By then you're inside super.

Unfortunately, the implication of this suggestion is that you can't use  
the native PopUps in IB. I don't think you can put them on a 2.x palette  
because IB treats them special. Does that kill the whole deal for you?

PopUpLists: can't live with 'em, can't shoot 'em in the head.

--
Gregory H. Anderson          | "We're very tolerant around here,
Benevolent Dictator-for-Life |  being only amateurs ourselves."
Anderson Financial Systems   | - Tortoise (Godel, Escher, Bach)
greg@afs.com  (Nextmail OK)  | 
Re: Getting a PopUpList's window
#1139
Author: David Griffith
Date: Fri, 14 Aug 1992 13:41
17 lines
1234 bytes
In article <1992Aug12.002320.2320@afs.com> greg@afs.com writes:
>
>You are doing an inherently problematic thing, because PopUpLists are NOT  
>controls, like TextFields and Buttons. They inherit through the Window  
>hierarchy and are actually subclasses of Menus. By definition, you cannot  
>ask a Window what Window it lives on. The Matrix lives on the PopUpList,  
>not the Window it appears to be on, so it's no help either. Even the cover  
>button is no help, because it's not directly attached to the PopUp.
>

I think NeXT should implement the concept of parent/child windows to
provide a generic solution to this problem (i.e. the PopUpList window
becomes the child of the main window). There would probably be many uses
for such a feature besides PopUpLists. Also, closing/hiding the parent
window could automatically close/hide the children.

Dave Griffiths
Re: Getting a PopUpList's window
#1154
Author: Subrata Sircar
Date: Fri, 14 Aug 1992 22:11
33 lines
2541 bytes
dhg@sinix.UUCP (David Griffith) writes:
>In article <1992Aug12.002320.2320@afs.com> greg@afs.com writes:
>>You are doing an inherently problematic thing, because PopUpLists are NOT  
>>controls, like TextFields and Buttons. They inherit through the Window  
>>hierarchy and are actually subclasses of Menus. By definition, you cannot  
>>ask a Window what Window it lives on. The Matrix lives on the PopUpList,  
>>not the Window it appears to be on, so it's no help either. Even the cover  
>>button is no help, because it's not directly attached to the PopUp.

So keep the button around.  (This is the reverse of my problem, which is
usually how to munge with the PopUp List itself, or it's matrix).  When
you create the PopUp programmatically, keep the button (perhaps in your list
of things to free) as an id instance variable.  Overhead is small, since it
is a pointer.

The other alternative is to create the popUp in IB, where you get a handle to
the button.  Now, reference the popUp with [button target], or add a category
to PopUp to return the matrix (which is what I do) and munge it directly.

>I think NeXT should implement the concept of parent/child windows to
>provide a generic solution to this problem (i.e. the PopUpList window
>becomes the child of the main window). There would probably be many uses
>for such a feature besides PopUpLists. Also, closing/hiding the parent
>window could automatically close/hide the children.

I'm not so sure about this, but I really hope PopUp list has been debugged
and better integrated into 3.0; it's kind of a bastard child now.

-- 
Subrata Sircar | ssircar@canon.com | Prophet & SPAMIT Charter Member
Canon Information Systems and I do not speak for each other on all things.
"I wish people wouldn't instantly assume that I am an idiot." (Valentine)
"A restaurant is a whorehouse that does food instead of sex." (Roger Lustig)
Re: Getting a PopUpList's window
#828
Author: J.B. Nicholson-Owens
Date: Sat, 15 Aug 1992 02:01
18 lines
1337 bytes
One small PopUp problem I haven't seen addressed is having a lot of
entries in a PopUp or PopDown (whatever those downward expanding PopUp
menus are called).  There needs to be something that is able to,
perhaps, scroll the choices up and down the way Mac pull-down menus do
when the menu is too long to display on the screen.

Has anything been done in 3.0 to handle this situation?

I wish that merely using a scrollView were a suitable replacement for
such problems, but the ability of the PopUp to give an infinite number
of choices as well as show the chosen one in a very small space and
almost instantly is *very* handy.  I would hate to have to revert to a
button bringing up a panel that had a scrollView in it.  That would
seem so cumbersome to me as a user.

-- 
-- Jeff (jeffo@ux1.cso.uiuc.edu)
-- No NeXTmail please
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads