• 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: NSTableView text editing notifications/delegation vs. attributed string cells?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView text editing notifications/delegation vs. attributed string cells?


  • Subject: Re: NSTableView text editing notifications/delegation vs. attributed string cells?
  • From: Douglas Davidson <email@hidden>
  • Date: Tue, 28 Feb 2006 09:37:30 -0800


On Feb 28, 2006, at 9:25 AM, Jim Correia wrote:

The notifications/delegate methods for control text editing look like this:

@interface NSObject(NSTextDelegate)
- (BOOL)textShouldBeginEditing:(NSText *)textObject; /* YES means do it */
- (BOOL)textShouldEndEditing:(NSText *)textObject; /* YES means do it */
- (void)textDidBeginEditing:(NSNotification *)notification;
- (void)textDidEndEditing:(NSNotification *)notification;
- (void)textDidChange:(NSNotification *)notification; /* Any keyDown or paste which changes the contents causes this */
@end


Suppose I have a cell for which -allowsEditingTextAttributes is true. What is the preferred way to get back the attributedString in textShouldEndEditing?

NSText doesn't appear to have attributed string accessor methods. I could certainly do the if ([textObject respondsToSelect:...]) dance here, but I'm wondering if I might have missed something obvious?


These probably aren't the methods you're looking for. The best thing is to act as the table view's delegate, and implement the methods defined in NSControl.h starting with control:textShouldBeginEditing:. The methods you list above are those that the controls themselves (such as NSTableView) implement to receive delegate messages from the field editor; in these methods they then call out to their own delegates using methods like control:textShouldBeginEditing:. If you were implementing a table view subclass, you could override the NSText delegate methods, but that would have to be done with great care.


The other thing is that in the AppKit as it stands, NSText is an abstract class; the concrete subclass used is NSTextView. The distinction between NSText and NSTextView is a historical artifact, and you may assume that field editors will be NSTextViews.

Douglas Davidson

_______________________________________________
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


  • Follow-Ups:
    • Re: NSTableView text editing notifications/delegation vs. attributed string cells?
      • From: Jim Correia <email@hidden>
References: 
 >NSTableView text editing notifications/delegation vs. attributed string cells? (From: Jim Correia <email@hidden>)

  • Prev by Date: Re: NSTableView text editing notifications/delegation vs. attributed string cells?
  • Next by Date: Re: NSTableView text editing notifications/delegation vs. attributed string cells?
  • Previous by thread: Re: NSTableView text editing notifications/delegation vs. attributed string cells?
  • Next by thread: Re: NSTableView text editing notifications/delegation vs. attributed string cells?
  • Index(es):
    • Date
    • Thread