• 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: Manipulate the NSTextview, several questions...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Manipulate the NSTextview, several questions...


  • Subject: Re: Manipulate the NSTextview, several questions...
  • From: Graham Cox <email@hidden>
  • Date: Wed, 8 Oct 2008 09:44:55 +1100


On 7 Oct 2008, at 6:50 pm, Cloud Strife wrote:

Hi everyone. I am using the NSTextview to perform some functions of my
application. I want to implement:
1. The NSTextiview has several lines of output, when the user click(or
double-click) one line of the text, I want to the NSTextview to highlight
the line which the user clicked with some light color, i.e. the light blue,
the light green and so on. Then how to?
2. Following the question 1, I also want to know which line the user select
and hence to get the content of the line. How to?


In order to describe my purpose clearly, assuming we have a nstextview with
content as following:


Line1: Content of Line1;
Line2: Content of LIne2;

OK, first problem - define "line". Since NSTextView will word-wrap text into as many lines as necessary there may not be a distinct line that you can select like that.


If you can define a line to mean "the characters between CRs and/or start and end of the text" then NSTextView might be made to play.

When the user click the line 1, the line 1 is highlighted by light- blue
mark.
And I can use some piece of code to know the user has selected line 1, and
retrieve the content of line 1:
"Line1: Content of Line1;"
as a nsstring object.


Can anyone tell me how to accomplish these tasks? Thank you very much for
any help.
Have a good day


You might be better off trying to accomplish this using NSTableView. Store each line in an array and use a table view to display each one. Then selecting a single distinct line is straightforward as you already have each one stored separately. Unless you're talking about pages and pages of text, a table view will be efficient enough for this.

hth,


Graham

_______________________________________________

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: 
 >Manipulate the NSTextview, several questions... (From: "Cloud Strife" <email@hidden>)

  • Prev by Date: Re: Wasted Space and Kernighan
  • Next by Date: Re: Getting the values from the selected row of a table?
  • Previous by thread: Manipulate the NSTextview, several questions...
  • Next by thread: Next Key View doesn't "go to" pushbutton
  • Index(es):
    • Date
    • Thread