NSSearchField clear button does not respond to click

I am trying to clear the field NSSearchFieldby clicking the clear button on the right. I can not click on it.

Here is a screen recording of what happens 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 does not work; I do not know how to fix this problem. Please suggest how to fix this.

+4
source share
2 answers

It is very strange. I got a solution by simply changing the rectangle TextBorderTypeto rounded, and this error got a fix, now I can click the clear button NSSearchFiled. and that working smooth as expected.

The old one in this transparent button does not respond:

enter image description here

Now with the clear change button:

enter image description here

+6
source

, , .

, mouseDown .

- (void)mouseDown:(NSEvent *)theEvent
{
    NSLog(@"SearchField.h mouseDown");
}
+1

Source: https://habr.com/ru/post/1589192/


All Articles