NSSearchField clear button does not respond to click
Asked Answered
G

2

5

I am trying to clear field NSSearchField by clicking on the clear button on the right side. I am not able to click on it.

Here is a screen recording of what's happening at my end:

enter image description here

I used the following code found by RND:

[[[self.SrcFiled cell] cancelButtonCell] setAction:@selector(clearSearchField:)];
[[[self.SrcFiled cell] cancelButtonCell] setTarget:self];

But it is not working; I have no idea how to fix this issue. Please suggest how to fix this.

Greathouse answered 21/5, 2015 at 10:50 Comment(3)
Why are you setting the action/target? It should work without any configuration...Skepticism
by default that not responding so i try to use above code. i did not set any method but without setting above code also that not respondingGreathouse
Jul 2021, This issue still exists!!Estragon
G
6

It's very strange. I got solution by just change TextBorderType rectangle to rounded and this error got fix now i can able to click on clear button of NSSearchFiled. and that working smooth as expected.

Old one in this clear button not responding:

enter image description here

Now with change clear button responding:

enter image description here

Greathouse answered 21/5, 2015 at 11:14 Comment(0)
A
1

I had exactly the same issue, but my border was already set as shown in the accepted answer.

I found that my override of the mouseDown event, was blocking this behaviour.

- (void)mouseDown:(NSEvent *)theEvent
{
    NSLog(@"SearchField.h mouseDown");
}
Anaplastic answered 30/8, 2016 at 15:38 Comment(1)
Always call super with these :)Matabele

© 2022 - 2024 — McMap. All rights reserved.