• 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 selecting text within a cell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTableView selecting text within a cell


  • Subject: Re: NSTableView selecting text within a cell
  • From: Corbin Dunn <email@hidden>
  • Date: Mon, 31 Jan 2011 08:53:23 -0800

On Jan 30, 2011, at 9:30 PM, Ben Golding wrote:

>
> I have an app with a NSTableView where the data is presented to the user.  When the user hits "Find", I'd like to be able to scroll the table view to the visible cell (easy enough) and then select the range that matched within that field (not so easy).
>
> At present, my code looks like:
>
> NSCell *cell = [csvTableView preparedCellAtColumn:col row:row];

hi ben,
This simply returns a prepared cell; not a copied cell.

> NSText *textEditor = [csvWindow fieldEditor:YES forObject:cell];

This won't give you what you want; the field editor is used by the control, not the cell. In this case, it is the tableView. The prepared cell doesn't have a particular knowledge of where it is in the table; it is just setup to be used for drawing. So, asking for the fieldEditor of a cell doesn't make sense.

>
> NSLog(@"Match: row %@, field %@, range(%d, %d)", [match row], [match field], [match range].location, [match range].length);
> [csvTableView scrollRowToVisible:row];
> [csvTableView scrollColumnToVisible:col];
> [textEditor setSelectedRange:[match range]];
>
> I feel like I need to between getting the textEditor for the window and calling -setSelectedRange:, I just don't know what.

You need to begin an editing session first; call this:

- (void)editColumn:(NSInteger)column row:(NSInteger)row withEvent:(NSEvent *)theEvent select:(BOOL)select;

then ask for the field editor:

NSTextView *textEditor = [csvWindow fieldEditor:YES forObject:table];

Then do whatever selection you want on it.


corbin

>
> 	Ben._______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >NSTableView selecting text within a cell (From: Ben Golding <email@hidden>)

  • Prev by Date: Re: NSTableView selecting text within a cell
  • Next by Date: Re: Help Book authoring tool?
  • Previous by thread: Re: NSTableView selecting text within a cell
  • Next by thread: Re: NSTableView selecting text within a cell [SOLUTION]
  • Index(es):
    • Date
    • Thread