nstextfield

How to capture user input in real time in NSTextField?

☆樱花仙子☆ 提交于 2019-12-09 19:36:30
问题 I can capture string when user click the button. and I also use the following method - (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor which declared in NSControlTextEditingDelegate Protocol. And when user begin editing, the button will be available. My Question is: How to make the button disable when user delete all text (make the textField empty without clicking button)? The above method seems can not do it... 回答1: Look at using the

NSTextField delegate notifications — how to get text?

半腔热情 提交于 2019-12-09 16:02:23
问题 I've been trying to learn to use Xcode, but I'm getting confused with how to register that NSTextField has changed. Essentially, I have an NSTextField and a button. Clicking the button does stuff with the text in the field. However, I want to be able to get the text of the field without needing to use the text field "Action:send on end editing." That is, I want to be able to enter text and immediately press the button, without hitting enter or tabbing out of the text box. It seems like the

Clickable url link in NSTextFieldCell inside NSTableView?

▼魔方 西西 提交于 2019-12-09 13:13:37
问题 I have a NSAttributedString that I'm using in a NSTextFieldCell. It makes several clickable url links and puts a big NSAttributedString inside the NSTextFieldCell. Whenever I am viewing the NSTextFieldCell normally and it's highlighted, I cannot click on the links. If I set the TableView so I can edit each column or row, when I click twice, go into Edit mode and view the NSTextFieldCell contents, my links show up and are clickable. When I click away from the row, I can no longer see clickable

How can I make my NSTextField NOT highlight its text when the application starts?

ぃ、小莉子 提交于 2019-12-09 05:21:14
问题 When my application launches, the first NSTextField is being selected like this: I can edit the NSTextField fine, but when I press enter to end the editing, the text becomes selected again, and the editing does not end. I followed the Apple tutorial here, and I had the same problem with the text field being perpetually highlighted. How do I stop this? I would like it so the text field is not the first responder of the app so it's not edited right away, and when it is being edited, clicking

NSNumberFormatter doesn't allow typing decimal numbers

混江龙づ霸主 提交于 2019-12-08 15:59:00
问题 I am totally bewildered using NSNumberFormatter. This should be totally simple but I can't get it to work. I'd like to set an NSTextField to allow typing decimal numbers, either with a decimal point or without. Here is what I'd think would work: NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; [formatter setNumberStyle:NSNumberFormatterDecimalStyle]; [formatter setMinimumFractionDigits:0]; [formatter setMaximumFractionDigits:4]; [formatter setAllowsFloats:YES]; [

Swift & NSTextField: How to work with Text Completion

*爱你&永不变心* 提交于 2019-12-08 13:29:00
问题 I want to create autocomplete list like this for NSTextField : I have found this: https://developer.apple.com/documentation/appkit/nscontroltexteditingdelegate/1428925-control optional func control(_ control: NSControl, textView: NSTextView, completions words: [String], forPartialWordRange charRange: NSRange, indexOfSelectedItem index: UnsafeMutablePointer<Int>) -> [String] Can somebody please explain how to use this on any example? I can't really understand. I tried to implement this, but

Set maximum characters (to one) in a NSTextfield in Swift

↘锁芯ラ 提交于 2019-12-08 03:40:09
问题 How do i set the maximum amount of characters in multiple NSTextfields (OSX cocoa app, NOT iOS) to one in Swift? Please explain how to do it, because I'm a complete newbie when it comes to OSX app development and therefore I don't understand short answers like "Use NSFormatter", because I have no idea what it is and how to implement it. Like Examples 回答1: You don't need to limit the characters a user will enter just only look at the first character entered. In fact, it is probably better

How do I update the expansion tooltip size after calling NSTextField setStringValue:?

大兔子大兔子 提交于 2019-12-08 03:08:19
问题 When a view contains an NSTextField with the expansion tooltip enabled and the text doesn't fit, then the user hovers the cursor over the field, OS X shows an expansion tooltip. If you then call setStringValue: to change the text content of the NSTextField , the expansion tooltip's size is not updated. For instance, if the original text was 100 characters long but the new text is only 50 characters long, hovering over the new text will show an expansion tooltip large enough for 100 characters

Sharing an NSDateFormatter between NSTextFields in view-based NSTableView?

一世执手 提交于 2019-12-08 02:25:41
问题 I've searched high and low for the answer to this, but alas, I'm here. As I know that NSDateFormatter objects are costly to create, I don't want to instantiate one for every NSTextField inside of my table. The problem I'm facing is that my table is view-based (as opposed to cell-based), and when attempting to connect a shared instance of a date formatter, I get the yellow warning symbol and this message: Unsupported Configuration: Outlet 'formatter' of 'Text Field Cell - Table View Cell' is

Cocoa: Avoiding 'Updates Continuously' in control binds

江枫思渺然 提交于 2019-12-08 01:34:18
问题 I have several panels that contain NSTextField controls bound to properties within the File's Owner object. If the user edits a field and then presses Tab , to move to the next field, it works as expected. However if the user doesn't press Tab and just presses the OK button, the new value is not set in the File's Owner object. In order to workaround this I have set Updates Continuously in the binding, but this must be expensive (EDIT: or at least it's inelegant). Is there a way to force the