nstextfield

NSTextField clicked link colour

不想你离开。 提交于 2019-12-22 17:04:11
问题 I have an NSTextField that contains an NSAttributedString which itself contains a clickable link. I've change the colour of the link for my own styling, however when I click on it it becomes blue and underlined. How can I stop this? 回答1: Seems that I'm not the only one with this problem, and there's a handy class to solve it: https://github.com/laevandus/NSTextFieldHyperlinks 回答2: This ( http://developer.apple.com/library/mac/#qa/qa1487/_index.html ) may help you. It will show you how to set

How to make a Multi-line (2 lines) label truncate the last line (OS X)

不想你离开。 提交于 2019-12-22 13:00:55
问题 I'm trying to make a multi-line label with 2 lines truncate the last line only. But it seems that, if I choose the Layout of that label as Truncates , my multi-line label becomes one-line. Here's what I want (I manually typed "..." for demonstration purposes): Here's what I have when I set my label as Truncates in IB (as you can see it still has 2 lines but acts as if it was only 1): Is this supposed to happen? If not, how can I achieve the truncate style of the first image? Thanks! 回答1: It

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 *)[

Suppressing the text completion dropdown for an NSTextField

半腔热情 提交于 2019-12-22 09:57:41
问题 I'm trying to create the effect of an NSComboBox with completes == YES, no button, and numberOfVisibleItems == 0 (for an example, try filling in an Album or Artist in iTunes's Get Info window). To accomplish this, I'm using an NSTextField control, which autocompletes on -controlTextDidChange: to call -[NSTextField complete:] , which triggers the delegate method: - (NSArray *)control:(NSControl *)control textView:(NSTextView *)textView completions:(NSArray *)words forPartialWordRange:(NSRange

How to intercept keystrokes from within the field editor of an NSTextField?

大憨熊 提交于 2019-12-22 08:25:18
问题 Intro When my custom NSTextField is in "text editing mode" and the field editor has been placed in front of it as firstResponder I no longer get the keystrokes through NSTextField.keyDown(...) . I understand that the keystrokes are now being routed through the field editor . Most online recommendations are to override the following method within the delegate of the custom NSTextField : control(_:textView:doCommandBySelector:) I have indeed overridden this method but it doesn't seem to get

No events such as 'Editing did Change' for a NSTextField?

試著忘記壹切 提交于 2019-12-22 04:47:31
问题 When I developed for the iPhone I had multiple events on touch that could be true for a button. (e.g. Editing did Change, Editing did End …) Now that I develop for Mac OSX I want my application to recognize multiple events in a NSTextField. How to do that? Is there an alternative for the events? Thanks! EDIT: May delegates be the key? 回答1: You need to set an object as the delegate of your NSTextField . As NSTextField is a subclass of NSControl , it will call the -controlTextDidChange: method

NSTextField - make selected text bold, italic or underline?

房东的猫 提交于 2019-12-21 05:45:17
问题 I have an NSTextField where the user can write text. I would like to be able to make 3 buttons: bold, italic and underline; these buttons should change the user selection in the textfield to either bold, italic or underline. Can anyone give me a pointer on how to do this? 回答1: The first thing is to enable rich text support, and you can do it either in Interface Builder by checking the "Rich Text" option in the inspector or by code using setAllowsEditingTextAttributes: . Then it's all about

NSTextField with rounded corners?

[亡魂溺海] 提交于 2019-12-21 05:23:07
问题 I'm trying to draw rounded corners around an NSTextField. I've subclassed NSTextField , tried the code below, but without any result... Any ideas? - (void)drawRect:(NSRect)dirtyRect { // black outline NSRect blackOutlineFrame = NSMakeRect(0.0, 0.0, [self bounds].size.width, [self bounds].size.height-1.0); NSGradient *gradient = nil; if ([NSApp isActive]) { gradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithCalibratedWhite:0.24 alpha:1.0] endingColor:[NSColor

Trouble with NSTextField in Swift using xcode 6.1 (OSX)

主宰稳场 提交于 2019-12-20 07:47:30
问题 I started Swift but not Objective C. Can someone teach me how to get and set the NSTextField in Swift using xcode 6.1 under OSX? 回答1: You get and set the value of an NSTextField with the stringValue property. For instance, if you have this @IBOutlet in your app: @IBOutlet weak var textfield: NSTextField! getting the value: println("textfield is \(textfield.stringValue)") setting the value: textfield.stringValue = "this is my string" 来源: https://stackoverflow.com/questions/27163375/trouble

Trouble with NSTextField in Swift using xcode 6.1 (OSX)

限于喜欢 提交于 2019-12-20 07:47:25
问题 I started Swift but not Objective C. Can someone teach me how to get and set the NSTextField in Swift using xcode 6.1 under OSX? 回答1: You get and set the value of an NSTextField with the stringValue property. For instance, if you have this @IBOutlet in your app: @IBOutlet weak var textfield: NSTextField! getting the value: println("textfield is \(textfield.stringValue)") setting the value: textfield.stringValue = "this is my string" 来源: https://stackoverflow.com/questions/27163375/trouble