NSTextView not talking to delegate?

  • I'm creating an NSTextView subclass, and then sending it
    setDelegate:self so that I can receive a textDidChange: message. But
    I never get it.

    I've looked at [textView delegate] with GDB, and it is indeed the
    same as self.

    What would cause this message not to be sent to the delegate?

    David Dunham    A Sharp, LLC
    Voice/Fax: 206 783 7404    http://a-sharp.com
    Efficiency is intelligent laziness.
  • On Dec 1, 2006, at 11:40 PM, David Dunham wrote:

    > I'm creating an NSTextView subclass, and then sending it
    > setDelegate:self so that I can receive a textDidChange: message.
    > But I never get it.
    > I've looked at [textView delegate] with GDB, and it is indeed the
    > same as self.
    > What would cause this message not to be sent to the delegate?

    Perhaps the message signature has a typo?

        - Scott
  • Am 02.12.2006 um 08:40 schrieb David Dunham:
    > I'm creating an NSTextView subclass, and then sending it
    > setDelegate:self so that I can receive a textDidChange: message.
    > But I never get it.

      It kinda worries me that you have to make an object its own
    delegate. Isn't there a method equivalent to textDidChange: in the
    NSTextView itself that you can override?

    Cheers,
    -- M. Uli Kusterer
    http://www.zathras.de
  • On Dec 2, 2006, at 8:20 AM, Uli Kusterer wrote:

    > Am 02.12.2006 um 08:40 schrieb David Dunham:
    >> I'm creating an NSTextView subclass, and then sending it
    >> setDelegate:self so that I can receive a textDidChange: message.
    >> But I never get it.
    >
    > It kinda worries me that you have to make an object its own
    > delegate. Isn't there a method equivalent to textDidChange: in the
    > NSTextView itself that you can override?

    It sounds more likely that he means "self" in terms of the object
    doing the setting (i.e. the controller or whatever).

    D
  • On 2 Dec 2006, at 08:41, Daniel Jalkut wrote:

    >> It kinda worries me that you have to make an object its own
    >> delegate. Isn't there a method equivalent to textDidChange: in the
    >> NSTextView itself that you can override?
    >
    > It sounds more likely that he means "self" in terms of the object
    > doing the setting (i.e. the controller or whatever).

    Yup.

    And it turned out that the NSTextView was indeed talking to its
    delegate -- which was another object entirely. I'd sent setDelegate
    from another place in my app, to deal with an NSTextView bug.

    David Dunham    A Sharp, LLC
    Voice/Fax: 206 783 7404    http://a-sharp.com
    "People seem to misinterpret complexity as sophistication" -- Niklaus
    Wirth
  • I'm interested in what NSTextView bug you're referring to. Care to
    share?

    --
    I.S.

    On Dec 2, 2006, at 12:56 PM, David Dunham wrote:

    > And it turned out that the NSTextView was indeed talking to its
    > delegate -- which was another object entirely. I'd sent setDelegate
    > from another place in my app, to deal with an NSTextView bug.
  • On 2 Dec 2006, at 12:40, I. Savant wrote:

    > I'm interested in what NSTextView bug you're referring to. Care
    > to share?

    I think this is the one where you can paste a graphic and it forgets
    the font you've been typing in. (Like most NSTextView bugs, it's easy
    to reproduce in TextEdit.) Here's the fix:

    // A bug in AppKit means that attachments (such as images) reset the
    typing attributes.
    // We fix that using the delegate method... (thanks to Keith Blount)
    - (NSDictionary *)textView:(NSTextView *)aTextView
    shouldChangeTypingAttributes:(NSDictionary*)oldTypingAttributes
    toAttributes:(NSDictionary *)newTypingAttributes
    {
    return [newTypingAttributes objectForKey:NSAttachmentAttributeName] ?
      oldTypingAttributes : newTypingAttributes;
    }

    David Dunham    A Sharp, LLC
    Voice/Fax: 206 783 7404    http://a-sharp.com
    Efficiency is intelligent laziness.
previous month december 2006 next month
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Go to today