Professional Web Applications Themes

delegate or subclass NSTextView? - Mac Programming

I can't quite figure out if I should focus on using the delegate methods of a NSTextView or if I should work on subclassing it. What I'd like is to have is a continuously updated "translation" line of text just under the user entered line of text (like DNA to protein, for instance). I could maybe figure this out better if I knew what commands get sent to a NSTextView delegate. Is there a list anywhere of the selectors that get sent by doCommandBySelector? Thanks for any tips...

  1. #1

    Default delegate or subclass NSTextView?

    I can't quite figure out if I should focus on using the delegate
    methods of a NSTextView or if I should work on subclassing it. What I'd
    like is to have is a continuously updated "translation" line of text
    just under the user entered line of text (like DNA to protein, for
    instance). I could maybe figure this out better if I knew what commands
    get sent to a NSTextView delegate. Is there a list anywhere of the
    selectors that get sent by doCommandBySelector?



    Thanks for any tips
    None Guest

  2. #2

    Default Re: delegate or subclass NSTextView?

    None <nonenone.com> wrote:
    > I can't quite figure out if I should focus on using the delegate
    > methods of a NSTextView or if I should work on subclassing it. What I'd
    > like is to have is a continuously updated "translation" line of text
    > just under the user entered line of text (like DNA to protein, for
    > instance). I could maybe figure this out better if I knew what commands
    > get sent to a NSTextView delegate. Is there a list anywhere of the
    > selectors that get sent by doCommandBySelector?
    If you look at the doentation, you'll find a list of delegate methods
    for NSTextView and its superclasses. You can tame the wild doentation
    with Cocoa Browser: <http://www.macupdate.com/info.php/id/10291>

    You probably want to make a delegate object for the user-entered text
    view, and then have that delegate object translate it and put it in the
    second text view. This is simpler, conceptually, and would be easier to
    understand if you're not all that intimately familiar with Cocoa.
    Paul Mitchum Guest

  3. #3

    Default Re: delegate or subclass NSTextView?

    In article <1g1niwd.mytc1j15odc3hN%usenetmile23.com.r3m0v3 >, Paul
    Mitchum <usenetmile23.com.r3m0v3> wrote:
    > None <nonenone.com> wrote:
    >
    > > I can't quite figure out if I should focus on using the delegate
    > > methods of a NSTextView or if I should work on subclassing it. What I'd
    > > like is to have is a continuously updated "translation" line of text
    > > just under the user entered line of text (like DNA to protein, for
    > > instance). I could maybe figure this out better if I knew what commands
    > > get sent to a NSTextView delegate. Is there a list anywhere of the
    > > selectors that get sent by doCommandBySelector?
    >
    > If you look at the doentation, you'll find a list of delegate methods
    > for NSTextView and its superclasses. You can tame the wild doentation
    > with Cocoa Browser: <http://www.macupdate.com/info.php/id/10291>
    >
    > You probably want to make a delegate object for the user-entered text
    > view, and then have that delegate object translate it and put it in the
    > second text view. This is simpler, conceptually, and would be easier to
    > understand if you're not all that intimately familiar with Cocoa.
    Sorry to be so dense, but I've read the doentation and the info in
    Cocoa Browser as well as all posts in deja that I can find on this
    subject, but still cannot figure it out. There is no list of selectors
    that are sent by doCommandBySelector, so I can't guess which message
    might be appropriate to override.

    But it turns out to work quite well for me if I do just subclass the
    NSTextView rather than trying to get the delegate to receive the
    correct messages. Now I just have a different novice type question. By
    subclassing NSTextView, my window no longer behaves correctly in the
    application; i.e. making changes to the text does not set the window to
    know that its content has been changed. I know I can implement the undo
    manager manually myself, but is there an easy way to re-hook up my
    subclassed nstextview to the default window behavior so I don't have
    to? I gather this is a result of making my own scrollview in IB using
    my subclass rather than the built in scrollview objects...

    Thanks again,
    None Guest

  4. #4

    Default Re: delegate or subclass NSTextView?

    None <com> wrote:
     
    > >
    > > If you look at the doentation, you'll find a list of delegate methods
    > > for NSTextView and its superclasses. You can tame the wild doentation
    > > with Cocoa Browser: <http://www.macupdate.com/info.php/id/10291>
    > >
    > > You probably want to make a delegate object for the user-entered text
    > > view, and then have that delegate object translate it and put it in the
    > > second text view. This is simpler, conceptually, and would be easier to
    > > understand if you're not all that intimately familiar with Cocoa.[/ref]
    >
    > Sorry to be so dense, but I've read the doentation and the info in
    > Cocoa Browser as well as all posts in deja that I can find on this
    > subject, but still cannot figure it out. There is no list of selectors
    > that are sent by doCommandBySelector, so I can't guess which message might
    > be appropriate to override.[/ref]

    Look for delegate messages that are sent by NSTextView. In Cocoa
    Browser, for NSTextView, they're marked 'Delegate Methods.' :-)
    Implement (some of) these in your NSDoent subclass, control-drag from
    the NSTextView to the File's Owner in IB, and connect it as the
    delegate. Voila. That's All You Have To Do. No subclassing and futzing
    around with view subclasses in IB.

    -doCommandBySelector is part of the NSResponder chain. There's an
    NSTextView delegate method (-textView:doCommandBySelector:) that lets
    your delegate object be part of that chain, via the text view, but it
    doesn't sound like something you need to deal with.
     

    This is why it's better to implement the delegate methods.
     

    No, it's just that you've overloaded some function that does something
    Cocoa needs in order update the little black dot in the little red candy
    button, or else you've upset the natural order of NSViews in IB. :-)

    Use delegates.
    Paul Guest

Similar Threads

  1. Losing Delegate On Postback
    By Chris A. in forum ASP.NET Building Controls
    Replies: 7
    Last Post: May 25th, 05:30 AM
  2. NSTextView problems plus a few others...
    By Per Bull Holmen in forum Mac Programming
    Replies: 6
    Last Post: September 18th, 12:01 AM
  3. impersonate/delegate problem
    By Jerry in forum ASP.NET Security
    Replies: 6
    Last Post: August 19th, 12:10 AM
  4. NSMutableAttributedString in an NSTextView
    By matt neuburg in forum Mac Programming
    Replies: 11
    Last Post: July 26th, 01:21 AM
  5. NSScrollView for NSTextView scrolls then snaps back
    By Harry Mahoney in forum Mac Programming
    Replies: 0
    Last Post: July 16th, 09:19 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139