Re: [Pyobjc-dev] Subclassing in Interface Builder
Brought to you by:
ronaldoussoren
From: Tony L. <to...@lo...> - 2003-02-21 18:10:44
|
At 11:51 AM -0500 2/21/03, bb...@ma... wrote: >On Friday, Feb 21, 2003, at 11:45 US/Eastern, Just van Rossum wrote: >>I'm just guessing, but perhaps you need to override awakeFromNib >>instead? > >Right. This is one of the more subtle aspects of IB based >programming. The objects are archived within the NIB and, upon nib >loading, are reconstituted from the archive, not instantiated. >Hence, the designated initializer will not be called. > >-awakFromNib is one possibility -- very useful because all >connections have been made. > >I beliver this is also an initWithCoder: or something like it that >can be used earlier. awakeFromNib: works perfectly. Thanks all. While we're talking about subtle aspects of IB programming... I have a few NSImageView controls on my window. The controls all have a custom class so that they can accept drag and drop operations. I would like to use the "target" outlet so I can make connections in IB between my view and actions on my controller. I can make the connection, but actually invoking it doesn't seem to work. Here is what I have tried: def performDragOperation_(self, sender): pasteboard = sender.draggingPasteboard() self._extract_pasteboard_info(pasteboard) try: print "action:", self.action(), "target:", self.target() self.sendAction_to_(self.action(), self.target()) except: import traceback traceback.print_exc() return YES The action() and target() accessors return None despite being hooked up in IB. The one bit of sample Objective C code I found used instance variables, not accessors, and those instance variables are not available to PyObjC: /Developer/Examples/InterfaceBuilder/bMoviePalette/SoundFileWell.m: 92: [self sendAction:_action to:_target]; -Tony |