• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: custom NSView: solved!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: custom NSView: solved!


  • Subject: Re: custom NSView: solved!
  • From: Matt Neuburg <email@hidden>
  • Date: Tue, 14 Sep 2004 17:00:31 -0700

On or about 9/14/04 4:13 PM, thus spake "email@hidden"
<email@hidden>:

Date: Tue, 14 Sep 2004 23:37:29 +0100
From: Peter Browne <email@hidden>
> The problem was this: I wanted an NSTextField to display as a string
> the coordinates of a mouse click in the custom view. Whenever
> mouseDown: was called, nothing would happen. The app built with no
> errors, but an NSLog showed the connection to the textfield to be
> broken when the string was sent. After being sent a working example by
> Matt Neuburg, comparing it with my own and fiddling around, I
> discovered what was going wrong. It seems that I had instantiated the
> custom view class in interface builder, and had connected the outlets
> using the instance, rather than the physical view itself in the
> interface builder window. I don't know if there is a rational
> explanation for this, but it would seem that my custom view outlets
> only worked if i did NOT use an instance to connect the outlets with.

Peter -

Just to be clear (and in case this helps any other newbies), the "physical
view itself in the interface build window" *is* an instance - it's the
instance in the window. The window is an instance, and so are all its
subviews.

The free-floating instance, which you got by saying Instantiate to the
class, was *another* instance. But since it wasn't the instance in the
window, it wasn't the instance being clicked on. The instance that *was*
being clicked on, the one in the window, didn't have its currtgt outlet
hooked up, so the setStringValue: message was being sent to nil. That's why
the click failed silently.

I can't *quite* tell whether the concept you need to get clear on is class
vs. instance or the question of what a nib is (that is, what is it that
you're doing when you do stuff in Interface Builder). But I hope that the
foregoing splashes cold water in the right place! :) m.

--
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
AppleScript: the Definitive Guide! NOW SHIPPING...! (Finally.)
http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt
Subscribe to TidBITS! It's free and smart. http://www.tidbits.com/



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: [Moderator] Cocoa and list resources
  • Next by Date: Re: controlTextDidChange, backspace possible?
  • Previous by thread: custom NSView: solved!
  • Next by thread: Distributing vs. re-using source code?
  • Index(es):
    • Date
    • Thread