开发者

Invoking a method on Space bar or Enter Press + MAC APP

开发者 https://www.devze.com 2023-03-29 01:12 出处:网络
I am developing a mac standal开发者_StackOverflowone app. I want to let user press enter on search button to get result from DB.

I am developing a mac standal开发者_StackOverflowone app.

I want to let user press enter on search button to get result from DB.

Is there any way we can give control to search when user presses 'Enter Key'. It works great on 'Space Bar'.

How can it be possible on 'Enter Key' in objective C.


Just set your button's "key equivalent" to the return key. To do that, select your button in the Interface Builder, open the inspector, and look for the entry labeled "key equivalent". Click it, and hit the return key. That's it!

But if you have a search box already, it's usually a better idea to do away with the search button. For example, Safari's Google search field doesn't have a "Google Search" button. Instead, hitting the return key at the end of the search phrase automatically triggers the search. If you want to do that, you just need to set the target and the action for the search box.

0

精彩评论

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