gpt4 book ai didi

objective-c - 当我按 Enter 键时,我的 NSTextField 会突出显示文本。?我只想 "enter"在字段中放置一个 "NewLine"字符,以便我可以继续输入

转载 作者:行者123 更新时间:2023-12-03 17:58:13 25 4
gpt4 key购买 nike

我只想“输入”在字段中放置一个“换行”字符,以便我可以继续输入。谢谢

- (void)someAction:(id)sender
{
NSString *s = [tf1 stringValue];
[tf1 setStringValue:[NSString stringWithFormat:@"%@%@",s, @"\nEnter\n" ]];
}

- (void)myRun:(NSButton*)btn
{
NSString *s = [tf1 stringValue];
[tf1 setStringValue:[NSString stringWithFormat:@"%@%@",s, @"hello\nthere" ]];
}


- (void)windowControllerDidLoadNib:(NSWindowController *)aController
{
[super windowControllerDidLoadNib:aController];
// Add any code here that needs to be executed once the windowController has loaded the document's window.

//[aController.window setFrame:CGRectMake(10,10,1000,600) display:TRUE];
[aController.window setFrame:NSMakeRect(10,10,1000,600) display:TRUE];
[aController.window setBackgroundColor:[NSColor grayColor]];



//NSButton *b1 = [[NSButton alloc] initWithFrame:CGRectMake(10, 530, 100, 30)];
NSButton *b1 = [[NSButton alloc] initWithFrame:NSMakeRect(10, 530, 100, 30)];
[b1 setTitle:@"Run"];
[b1 setAction:@selector(myRun:)];
[aController.window.contentView addSubview:b1];

tf1 = [[NSTextField alloc] initWithFrame:NSMakeRect(10, 10, 600, 500)];
[aController.window.contentView addSubview:tf1];
[tf1 setTarget:self];
[tf1 setAction:@selector(someAction:)];

}

最佳答案

关于objective-c - 当我按 Enter 键时,我的 NSTextField 会突出显示文本。?我只想 "enter"在字段中放置一个 "NewLine"字符,以便我可以继续输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10358056/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com