nstextfield

Make NSComboBox Appear when NSTextField is clicked

末鹿安然 提交于 2019-12-12 01:06:02
问题 How can I make an NSComboBox disappear when an NSTextField is clicked? This is the code I'm using: Class comboBox: (used as custom class for my NSComboBox in the interface builder) comboBox.h: #import <Cocoa/Cocoa.h> @interface comboBox1 : NSComboBox -(void)Hide; @end comboBox.m: #import "comboBox1.h" @implementation comboBox1 -(void)Hide { [self setHidden:YES]; } @end Class txtField: (used as custom class for my NSTextField in the interface builder) txtField.h: #import <Cocoa/Cocoa.h>

Changing text field repeatedly in a loop only displays one final value [duplicate]

烈酒焚心 提交于 2019-12-11 20:23:55
问题 This question already has answers here : NSTextField waits until the end of a loop to update (4 answers) Closed 5 years ago . I wish to create a loop that increments an integer every ten seconds, and does this one hundred times. But when I use this code: - (IBAction)loopTest:(id)sender { } - (IBAction)beginLoop:(id)sender { for (i=0;i<100 ;i++ ) { testingLoops++; NSString *feed = [NSString stringWithFormat: @"%d", testingLoops]; self.feedLabel.stringValue = feed; [NSTimer

NSTextView or NSTextField automatically resize bounds / frame?

江枫思渺然 提交于 2019-12-11 18:18:04
问题 I'm trying to use either an NSTextView or NSTextField which displays text that I am adding via textField.stringValue = [dictionary objectForKey:@"info"]; The problem is I need the bounds / frame of the text area to vertically re-size to show all of the text. The text varies from a couple of words (1 line) to a paragraph or two. When I try [textField sizeToFit]; It re-sizes the whole thing down to a single line which is absurdly too long (and goes off view). I need it to auto re-size its width

How to resize NSTextField dynamically?

落爺英雄遲暮 提交于 2019-12-11 17:34:07
问题 I want an NSTextField to get bigger as the user types, and smaller as backspace is pressed etc. The only thing I've found is [textField sizeToFit] but that doesn't run dynamically, it's just a one off resizing. Is there a property or something I need to set? p.s. I only need it to resize horizontally (single line text). 回答1: Set a delegate on the NSTextField which implements - (void)controlTextDidChange:(NSNotification *)aNotification Every time the delegate gets called resize the control per

Adding non editable NSTextField as a label into another NSTextField

五迷三道 提交于 2019-12-11 11:06:57
问题 I am trying to implement a custom NSTextField that a) changes color when active and b) has a label in the top left hand corner. I have the following implementation: In TestTextField.h @interface TestTextField : NSTextField - (id)initFullWidthWithLabel:(NSString *)label andPreset:(NSString *)preset; ... @end In TestTextField.m @interface TestTextField() { BOOL _thisFieldIsActive; } @property (nonatomic, strong) NSTextField *label; @end @implementation TestTextField - (id)initFullWidthWithLabel

Clearing NSTextfield bound to a nsmutablestring

孤者浪人 提交于 2019-12-11 10:44:00
问题 I have a text field bound to a nsmutableablestring. In the action item for a button I want to clear this string but it's throwing an exception saying it's immutable. Member variable is NSMutableString* firstName; Property for binding to the text field is declared in .h @property (copy) NSMutableString* firstName; In the action for the button the following line throws an exception [firstName setString:@""]; I don't have any trouble reading the value in firstName to access what is in the text

Binded NSTextField doesn't update the entity until it lose the focus

夙愿已清 提交于 2019-12-11 05:09:57
问题 I have a Core Data project. Basically I have an NSTableView where I add some entities (using the "add:" selector), double clicking on the TableView opens a new NSWindow where is possible to edit the entity using some NSTextFields. Each text field is binded to an attribute of the entity. Everything is working fine, except the fact that the entity's attributes are updated only when a textfield lose the focus. If I write on the first text field and then I move to the second one my entry is saved

Dynamic Results and Covering Data

五迷三道 提交于 2019-12-11 04:41:19
问题 Today I have a question that sprouted off of this one: Database Results in Cocoa. It's regarding using the data that was returned by a database to create a certain number of questions. I am using a form of the following code (this was posted in the question). NSMutableDictionary * interfaceElements = [[NSMutableDictionary alloc] init]; for (NSInteger i = 0; i < numberOfTextFields; ++i) { //this is just to make a frame that's indented 10px //and has 10px between it and the previous NSTextField

NSUndoManager custom coalescing changes to NSTextField results in crash

匆匆过客 提交于 2019-12-11 04:17:00
问题 I have a basic Cocoa app using NSUndoManager to support undo/redo. My data model's title can be updated by editing an NSTextField . Out of the box NSTextField supports coalescing changes into a single "Undo Typing" undo action so that when the user presses Cmd-Z, the text is reverted in full instead of only the last letter. I'd like to have a single "Undo Changing Model Title" undo action that undoes multiple changes to my model's title (made in a NSTextField). I tried grouping changes myself

How to disable context menus with right mouse click in an NSTextField (Cocoa)?

吃可爱长大的小学妹 提交于 2019-12-11 03:57:22
问题 I'm working on a Cocoa application that has editable text fields. These text fields need to accept values but don't need to be spell checked or use any of the other options given in the default context menu. I've read that the easiest way to remove the right click/ opt + click context menu is to override the function: rightMouseDown:(NSEvent *) I've done this in a custom NSTextfield class. This fix blocks the user from right clicking when the text box is enabled and unselected, but as soon as