Questions tagged [nstextfield]

NSTextField object belongs to Apple's class. It's a kind of NSControl that displays text that the user can edit or select.

An NSTextField object is a kind of NSControl () that displays text that the user can select or edit and that sends its action message to its target when the user presses the Return key while editing.

The NSTextField () class uses the NSTextFieldCell () class to implement its user interface.

References:

1028 questions
24
votes
4 answers

Forcing a Cocoa text field to end editing

I have a view based gui that contains a text field for each gui item. When I select another menu item I want my text fields to exit out of editing mode. I could not find anyway to do this in the nsTextField docs. Any ideas?
Mike2012
  • 7,629
  • 15
  • 84
  • 135
23
votes
4 answers

Can't paste (Command+V) into an NSTextField

For some reason, an NSTextField isn't allowing me to paste anything into it using Command+V, though I can paste into it if I right-click and click 'Paste'. Why is this happening and how do I fix it?
Chetan
  • 46,743
  • 31
  • 106
  • 145
22
votes
3 answers

NSTextField with shadow?

I'd like the NSTextFields I set up in Interface Builder to have shadows. I've implemented a way to do this which seems to work, but I'm not sure if it's the right way. What I did is subclass NSTextFieldCell as follows and then set my subclass as the…
sam
  • 3,399
  • 4
  • 36
  • 51
20
votes
8 answers

Not being able to edit NSTextField on NSPopover even though Editable behavior is set

I have an application, which open popover with NSTextField. The text field is not editable. Behavior for text field is set to Editable. I still can paste and copy text to this field but i can't edit it. Anyone knows, what can be wrong?
agent-10
  • 361
  • 2
  • 9
20
votes
2 answers

make nstextfield single line

how to make NSTextField really single line? I created a text field programmatically. when the return key is pressed, all text is selected. but I can still paste multiple lines of text. And when I press Arrow-right or Arrow down, it scroll to the…
Jensen
  • 1,653
  • 4
  • 26
  • 42
19
votes
4 answers

NSTextField Vertical alignment

I am creating cocoa app in which i created NSTextField programmatically like this, NSView *superView = [[NSView alloc] initWithFrame:NSMakeRect(0, 300, 1400, 500)]; NSTextField *myTextField = [[NSTextField alloc] initWithFrame:NSMakeRect(180, 100,…
iUser
  • 1,075
  • 3
  • 20
  • 49
18
votes
1 answer

SwiftUI: Remove 'Focus Ring' Highlight Border from macOS TextField

I used the below code to create a custom search bar in SwiftUI. It works great on iOS / Catalyst: ...but when running natively on macOS, the 'focus ring' highlighted border styling (when the user selects the text field) rather ruins the…
TheNeil
  • 3,321
  • 2
  • 27
  • 52
18
votes
2 answers

NSControl's setCellClass is deprecated in OS X 10.10 what's the alternative for overriding NSTextField's cell class?

I'm attempting to follow the post linked below to override the NSCell of a NSTextField but it looks like the setCellClass method is now deprecated in OSX 10.10. How to make NSTextField use custom subclass of NSTextFieldCell? How should one override…
Camsoft
  • 11,718
  • 19
  • 83
  • 120
18
votes
7 answers

How to change NSTextField text color on row selection?

For cocoa, I have an NSTableView set to be view based. When a row is selected, the text fields change their color to white. How do I keep it black? I should also note that the Highlight is set to Source List (it does the same thing on…
joels
  • 7,249
  • 11
  • 53
  • 94
17
votes
4 answers

NSString boundingRectWithSize slightly underestimating the correct height - why?

I'm attempting to resize a text field / view automatically depending on its current width. In other words I want the width to stay constant but resize the height according to the text supplied to it. It seems to be working but for some reason is…
Desh__
  • 899
  • 1
  • 10
  • 16
16
votes
4 answers

Listen to a value change of my text field

I'm trying to understand how to catch a "text changed" event from a text field in my window. I'm used to Java's "action listeners", and can't find anything similar in Objective-C/Cocoa. I searched for quite a while and found the "key value…
Eike Cochu
  • 3,249
  • 7
  • 34
  • 57
16
votes
3 answers

NSTextField placeholder text doesn't show unless editing

I set the placeholder text of my NSTextField in Interface Builder, but the placeholder text doesn't show until I click inside the text field to edit it.
indragie
  • 18,002
  • 16
  • 95
  • 164
16
votes
2 answers

Color attribute is ignored in NSAttributedString with NSLinkAttributeName

In an NSAttributedString, a range of letters has a link attribute and a custom color attribute. In Xcode 7 with Swift 2, it works: In Xcode 8 with Swift 3, the custom attributed color for the link is always ignored (it should be orange in the…
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
16
votes
4 answers

Select next NSTextField with Tab key in Swift

Is there a way to change the responder or select another textfield by pressing tab on the keyboard, in Swift? Notes: It's for a fill in the blank type application. My VC creates a list of Words [Word], and each of those words has its own WordView -…
Aaron
  • 1,312
  • 3
  • 14
  • 25
14
votes
2 answers

Focus NSAlert accessory item

I have an NSAlert item that uses an NSTextField as an accessory item to provide an prompt-like dialog box. The only problem that I have is that when the alert is ran the text field is not focused. I tried looking for a way to change NSAlert's first…
JohnM
  • 161
  • 5
1
2
3
68 69