nstextfield

NSTask character output to NSTextField unbuffered as continuous stream

╄→гoц情女王★ 提交于 2019-12-11 03:32:50
问题 What I want to accomplish is to start a command line (CL) task (wrapped NSTask) and pipe (NSPipe) the character output through an NSTextField label in my UI, in real-time as a stream of characters. The purpose of the textfield is not to capture the output in any way, or even allow it to be read. It’s just to display it, partly as a UI decoration and partly as a kind of progress indicator. I want the user to see a stream of characters just flowing by (fast) as the CL task does its work. I know

Set border for NSTextField

邮差的信 提交于 2019-12-11 01:54:53
问题 Wow, I've really fallen down the rabbit hole. I'm trying to have text on the background of part of a UI and a text field as another part, e.g. the birthday in: I then want to repurpose that text filed to allow text entry. So I do something like: myTextFieldName.editable = true myTextFieldName.backgroundColor = NSColor.textBackgroundColor() and I get something like: Which is all well and good, but then I note the nice thin border around the text field below it. So I think, I need a border! I

NSTextField setStringValue: append strings to NSTextField

浪子不回头ぞ 提交于 2019-12-10 21:29:42
问题 I have some 10 buttons with different names each.On selecting each button I need to append the button's title to NSTextField without removing the older string. I have tried in the following way. - (IBAction)nextButton:(NSButton*)sender { int tag = [sender tag]; if (tag==1) { [resultField setStringValue:[sender title]]; } else if (tag==2) { [resultField setStringValue:[sender title]]; } else if (tag==3) { [resultField setStringValue:[sender title]]; } else if (tag==4) { [resultField

Send action from NSTextField when on key up instead of return

倖福魔咒の 提交于 2019-12-10 19:49:50
问题 I want to show the number of characters left for a new tweet, after a key has been lifted. Currently, this only happens if return is lifted: - (IBAction)updateCharacterCountFromNewTweetField:(id)sender { [newTweetCharacterCount setIntValue:140 - [[sender stringValue] length]]; } This action is connected to an NSTextField (NOT A UITextField!!): This is terrible for users, because they want to see the character count immediately, not just after pressing return. Can anyone help me out? Thanks.

NSTextField continuous update

不问归期 提交于 2019-12-10 17:11:53
问题 I can't figure out how to get an NSTextfield to update automatically, without having to press "Return" or click another text field. My goal is to input a number into a field and have the other fields update simultaneously. I tried clicking "Continuous" in the text field attributes but it doesn't seem to do anything. Here is my interface file: #import <Foundation/Foundation.h> @interface InchController : NSObject { IBOutlet NSTextField *centimetersTextField; IBOutlet NSTextField

Cocoa: How to bind a boolean property to NSCellStateValue?

此生再无相见时 提交于 2019-12-10 14:38:59
问题 I would like to bind the boolean enabled property of an NSTextField to the state of an NSButton . I already tried adding a custom NSValueTransformer that transforms the state of the NSButton into NSNumber . However, in that scenario the text fields are disabled all the time for some reason. My second approach: To bad fails also since NSValueTransformer does not offer return primitives types such as BOOL . Example: The screenshot shows an example in which the text fields are disabled because

Cocoa Can I Hide / Show an NSTextField / NSSecureTextField

妖精的绣舞 提交于 2019-12-10 14:29:10
问题 Is there a way to turn secureTextField on and off in Cocoa? (OSX). I'd like users to have the option to see their passwords. In iOS, I can do something like [textField setSecureTextEntry:YES]; I found [secureTextField setEchoBullets] but that's not what I want. Any help appreciated. 回答1: For me works perfectly to have two different cells in the same NSTextField and switch between them. void osedit_set_password_mode(OSEdit *edit, const bool_t password_mode) { OSXEdit *ledit = (OSXEdit*)edit;

Detect paste on NSTextField

梦想与她 提交于 2019-12-10 13:27:26
问题 I'm trying to handle a paste operation on a NSTextField . I found a similar article but for NSTextView . I tried code similar to this by overriding NSTextField and putting: - (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pboard { return [super readSelectionFromPasteboard: pboard]; } But this method seems to never be called. Any suggestions on how to detect a past on NSTextField? 回答1: You could use the NSTextFieldDelegate delegate method - (BOOL) control:(NSControl*) control textView:

How to make NSTextField use custom subclass of NSTextFieldCell?

梦想的初衷 提交于 2019-12-10 04:12:16
问题 I've been looking for a solution to make my NSTextField bottom-aligned and I've found this and adjusted it for my needs. So now I have this custom NSTextFieldCell but how do I tell my NSTextFields to use this class (programmatically)? 回答1: Have you tried setCell: method of the NSControl class? - (void)setCell:(NSCell *)aCell 回答2: Since you ask how to do it programmatically, you can also use the setCellClass: method on your NSTextField subclass. Call it in the load or initialize class methods:

Vertically Centre Text in NSSecureTextField with subclassing

眉间皱痕 提交于 2019-12-10 01:36:52
问题 I'm trying to vertically centre text in my NSTextFields, but one of them is for a password, so it's a NSSecureTextField. I've set it's class to be MDVerticallyCenteredSecureTextFieldCell with the following implementation: - (NSRect)adjustedFrameToVerticallyCenterText:(NSRect)frame { // super would normally draw text at the top of the cell NSInteger offset = floor((NSHeight(frame) - ([[self font] ascender] - [[self font] descender])) / 2); return NSInsetRect(frame, 0.0, offset+10); } - (void