nssearchfield

How to change background color of NSSearchField (like in Messages app in OS X)

浪子不回头ぞ 提交于 2021-01-21 09:15:29
问题 I need to get this appearance of NSSearchField But it seems to be impossible to set backgroundColor with standard methods of Interface Builder. How i can achieve this? Subclassing NSSearchField and NSSearchFieldCell didn't help, because i loose all animations (when you click on search field and icon+text sliding to left) when implementing my own draw methods. 回答1: What your screenshot shows is just the standard look of NSSearchField when being placed under an NSVisualEffectView . That is, the

Contextual menu with search result for a NSSearchField

不问归期 提交于 2020-01-04 09:30:31
问题 I would like to have a contextual menu that shows search results as text is entered in a search field. This is an image of the default mail app in OS X that does this. I know how to filter an array of strings according to the search request of the user, but I do not know how to display it this way. I am using Swift and for a Cocoa application. Any help is appreciated. 回答1: Building from the previous answer, here is a simple Swift 3 class which you can use to automatically handle recent

Hiding the lupe icon of a NSSearchField

我的梦境 提交于 2019-12-22 11:28:44
问题 I’m using a NSSearchField (not subclassed). When it’s not focused, the placeholderString is centered. But the lupe icon on the left appears a bit offset, so in fact the whole thing appears not to be centered. Is it possible to hide the lupe icon? 回答1: There is not any direct access to the icon, so that a workaround is first access to the NSSearchField cell (casted as shown), and afterwards access to its button cell. self in this example is an instance of NSSearchField [(NSButtonCell *)[

How to make NSSearchField send action upon autocompletion?

流过昼夜 提交于 2019-12-17 19:43:29
问题 This question seems straightforward but I've tried everything I can think of, and Googled for hours. I have an NSSearchField that does autocomplete, basically copying Apple's SearchField sample code. I have turned off "Sends Whole Search String" in IB because I don't want to do the search until the user has finalized their text entry, and don't want to do multiple searches (they are expensive). As the user types in the field, when they press enter, specifying that they accept the current

Overriding NSSearchFieldCell causes placeholder not centered

99封情书 提交于 2019-12-11 01:58:53
问题 I'm doing some custom drawing in a NSSearchFieldCell subclass. However overriding any of its two drawing methods causes the placeholder text not aligned. For example, just by using this custom NSSearchFieldCell subclass that overrides NSCell 's drawing method would cause the placeholder text to be left-aligned. class CustomSearchFieldCell: NSSearchFieldCell { override func draw(withFrame cellFrame: NSRect, in controlView: NSView) { super.draw(withFrame: cellFrame, in: controlView) } override

Hiding the lupe icon of a NSSearchField

故事扮演 提交于 2019-12-06 13:50:36
I’m using a NSSearchField (not subclassed). When it’s not focused, the placeholderString is centered. But the lupe icon on the left appears a bit offset, so in fact the whole thing appears not to be centered. Is it possible to hide the lupe icon? There is not any direct access to the icon, so that a workaround is first access to the NSSearchField cell (casted as shown), and afterwards access to its button cell. self in this example is an instance of NSSearchField [(NSButtonCell *)[(NSSearchFieldCell *)self.cell searchButtonCell] setTransparent:YES]; Deafault Search Field: Hidden/Transparent

Mail like search field with tokens (Mac OS X 10.7)

时光怂恿深爱的人放手 提交于 2019-12-06 01:31:38
问题 Is there a standard control for developers to get the search field behavior like in Mail (Mac OS X 10.7) to make advanced searches with tokens? In Mail the tokens are used to visualize a search for a mail which for example was sent by a person with the name "Steve Jobs". I try to accomplish the same but in another context. 回答1: What your looking for is called a token field. See the Token Field Programming Guide. (Also documented on the CocoaDev Wiki) 来源: https://stackoverflow.com/questions

Mail like search field with tokens (Mac OS X 10.7)

心已入冬 提交于 2019-12-04 04:23:10
Is there a standard control for developers to get the search field behavior like in Mail (Mac OS X 10.7) to make advanced searches with tokens? In Mail the tokens are used to visualize a search for a mail which for example was sent by a person with the name "Steve Jobs". I try to accomplish the same but in another context. What your looking for is called a token field. See the Token Field Programming Guide . (Also documented on the CocoaDev Wiki ) 来源: https://stackoverflow.com/questions/8643690/mail-like-search-field-with-tokens-mac-os-x-10-7

How can I pass a parameter to a selector?

怎甘沉沦 提交于 2019-12-01 06:40:53
问题 I have an NSSearchField: [searchField setAction:@selector(doSearchWithQuery:)]; Here is my doSearchQuery: -(void)doSearchWithQuery:(NSString*)query{ How can I pass the contents of my searchfield into doSearchWithQuery? 回答1: You can't do exactly what you're describing. A selector doesn't do anything or accept any parameters — it's just the name of the message to send. You can only pass arguments when you actually send a message. However, controls always pass themselves as an argument to their

How to prevent NSSearchField from overwriting entered strings using the first autocompletion list entry?

安稳与你 提交于 2019-11-29 07:35:19
I am looking for a way to create an nssearchfield that behaves as follows: user types in text based on matches an autocompletion drop-down appears the text in the search field does not autocomplete to the first item in the list The point is, my string matching searches for any substring and autocompletion in the text field would not work because it would overwrite my entered string. In fact it seems this should be the default behaviour, or am I misunderstanding the purpose of a search field? Typing further would restrict the list further and further, but only after selecting an item in the