如何在NSTextView中使用SPACE而不是TAB [英] How do I use SPACE instead of TAB in NSTextView
问题描述
我只知道如何在NSTextView中修改标签宽度
NSMutableParagraphStyle * paragraphStyle = [[self defaultParagraphStyle] mutableCopy];
[paragraphStyle setTabStops:[NSArray array]];
[paragraphStyle setDefaultTabInterval:tabWidth];但是,有没有办法在NSTextView中使用4个SPACES而不是TAB? $
解决方案好吧,晚了,但我会发布我的答案,以防其他一些可怜的灵魂与这个困难。
我一整天都在努力,最终在
总而言之,我在文本中所做的是查看委托:
- (BOOL)textView:(NSTextView *)aTextView doCommandBySelector:(SEL)commandSelector {
if (commandSelector == @selector(insertTab :)){
[aTextView insertText:@];
return YES;
}
return NO;
}
看起来工作正常。
撤消也有效。
I just know how to modify the tab width in NSTextView
NSMutableParagraphStyle *paragraphStyle = [[self defaultParagraphStyle] mutableCopy];
[paragraphStyle setTabStops:[NSArray array]];
[paragraphStyle setDefaultTabInterval: tabWidth];
But, is there any way to use 4 SPACES instead of TAB in NSTextView?
解决方案 Well, it's late, but I'll post my answer in case some other poor soul is struggling with this.
I''ve been struggling with this all day, and finally found the answer at cocoabuilder
In summary, what I did was, in my text view delegate:
- (BOOL)textView:(NSTextView *)aTextView doCommandBySelector:(SEL)commandSelector {
if (commandSelector == @selector(insertTab:)) {
[aTextView insertText:@" "];
return YES;
}
return NO;
}
Seems to work fine.
Undo works also.
这篇关于如何在NSTextView中使用SPACE而不是TAB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!