PDA

View Full Version : Need help with NSTextView


Mars_999
2004.01.06, 04:01 AM
I have just got textview up and running. I don't want the user to be able to modify the text but be able to click on the text(whole line) and select it so I can use the string for loading files. Is this possible with NSTextView? Also how do I clear the textview? Thanks

Codemattic
2004.01.06, 04:20 AM
in IB's Info ToolPanel (command-I) under attributes (command-1) you can make a NSTextView uneditable but still selectable. Or you can use the methods [myNSTextView setEditable:NO] and [myNSTextView setSelectable:YES].

I think you can clear the textview by using the method ñ setSelectedRange: to select the entire text and then ñ insertText: with an empty string. It sure seems like there should be an easier way - Im probably missing it - so if anyone knows of one let us know.

hth,
Codemattic

Steven
2004.01.06, 09:01 AM
[myTextView setString:[NSMutableString string]];
or something like that

Mars_999
2004.01.06, 10:54 AM
Well codemattic the problem with the IB option was/is if you deselect editable and try to post your text to the view you get nothing. Because the function setEditable is called before hand and is to late. So I found that same function you said and put that after the posting of my text and that did the trick. I still have to try the clear text idea, and yes you would think their would be a clearView or something.