objectiveccoder001
objectiveccoder001

Reputation: 3031

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 command in, it deletes what ever's in the NSTextField?

Thanks, Elijah

Upvotes: 1

Views: 443

Answers (1)

Jonathan Grynspan
Jonathan Grynspan

Reputation: 43472

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];
}

Upvotes: 4

Related Questions