开发者

Change default insertTab: action in NSSearchfield

开发者 https://www.devze.com 2023-03-09 02:55 出处:网络
I have a view with a nssearchfield a nstableview and a nsmatrix with three radiobuttons. Using delegates i change the selected radiobutton when the searchfield is the firstresponder and the user press

I have a view with a nssearchfield a nstableview and a nsmatrix with three radiobuttons. Using delegates i change the selected radiobutton when the searchfield is the firstresponder and the user press tab, that works perfectly but what i want is that the searchfield don't loose the firstresponder when the user 开发者_开发技巧press tab


You can sub class NSSearchField and add this function

- (BOOL)resignFirstResponder {
    return NO;
}

It will refuse to relinquish first responder status.

Another way is catch the windowDidUpdate notification. These are sent whenever anything changes, including change of focus, so you can check for the firstResponder and make it become first responder again.

[searchField becomeFirstResponder];
0

精彩评论

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