Re: NSTextView & Tabs ...
Re: NSTextView & Tabs ...
- Subject: Re: NSTextView & Tabs ...
- From: Ashley Clark <email@hidden>
- Date: Tue, 5 May 2009 11:55:00 -0500
On May 5, 2009, at 9:42 AM, Mic Pringle wrote:
I'm working on a project that accepts user input via an NSTextView
instance, but I would like to have a user-defined number of spaces
inserted when the tab key is pressed. Similar to how TextMate allows.
What is the best way to acheive this ? NSLayoutManager or key press
events ?
Any help will be greatly appreciated.
One way to accomplish this would be to implement this method on your
NSTextView delegate (typed in Mail, YMMV):
- (BOOL)control:(NSControl*)control textView:(NSTextView*)textView
doCommandBySelector:(SEL)commandSelector
{
if (commandSelector == @selector(insertTab:)) {
[textView insertText:spacesForTabsString];
return YES;
}
return NO;
}
Ashley
_______________________________________________
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