开发者

Objective C NSTextField keeps text in box highlighted when command is sent

When I press enter on an NSTextField to send what ever's in the text field, it sends it, but highlights what ever's in the NSTextField. Does anyone know how to make it so that once it sends the comma开发者_如何学Gond in, it deletes what ever's in the NSTextField?

Thanks, Elijah


If you haven't already, assign a target and action to the text field. Here's your action method:

- (IBAction)sendText: (id)sender {
    // Whatever else you were doing.
    // ...

    // Add this:
    [sender setStringValue: @""];
    // Optionally, to make it *not* the first responder:
    [[sender window] makeFirstResponder: nil];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜