nstextfield

How to set NSFormatter to accept negative integer values

The problem i have is when the formatter gets the string "-" or empty it fails to accept it. This makes entering a negative number a little bit uncomfortable. It also requires me to leave at least one digit in the field, which is also far from comfortable. Is there any way how a formatter would accept this as 0. My formatter works in N...

Can't successfully register undo from NSTextField

I have a simple document-based application that simply creates a custom XML file. It uses an Outline View to navigate the XML document. When an item in the Outline View is selected a custom view is displayed as a sub view of the document view that allows the user to enter in data. On one of the views has a NSTextField. It has its "Al...

I need to do some advanced text styling of NSTextFieldCell.

First i need some background color on the text only. Like the headers in the F-Script Browser Setting [cell setBackgroundColor: [NSColor blueColor]]; colors the whole cell space not only the text. Also i would need underlined and strikeout text. And to make things readable i would finally like to change the colors (foreground/backgro...

Disable/Enable NSButton if NSTextfield is empty or not

Hello! I´m newbie with cocoa. I have a button and a textField in my app. I want the button disabled when the textfield is empty and enabled when the user type something. Any point to start? Any "magic" binding in Interface Builder? Thanks [EDITED] I´ve tried to set the appDelegate as the NSTextfield´s delegate and added this method ...

NSTextField value bound to NSObjectController won't accept text input or changes

Here's what I've done so far: I have created a class that contains an NSNumber. I instantiated this class in my nib by dragging this object in the document window. I brought an NSObjectController into the document window to manage this object. I changed the class and keys in the attributes window. I dragged a connection from this obj...

NSManagedObjectContext save causes NSTextField to lose focus

This is a really strange problem I'm seeing in my app. I have an NSTextField bound to an attribute of an NSManagedObject, but whenever the object is saved the textfield loses focus. I'm continuously updating the value of the binding, so this is far from ideal. Has anyone seen anything like this before, and (hopefully) found a solution? ...

Use Multiple NSFormatters for the same NSTextfield

I have a textfield that I would like to use for multiple types of input. I have two custom NSFormatter classes that I would like to use for that field depending on what kind of input the user would like to provide. The input type is selected by a popup button before data is entered in the text field. I have an IBAction for the popup butt...

Creating a label using NSTextField is blurry

Hi, I'm trying to create a label programmatically using NSTextField, but it comes out blurry: screenshot This is my code so far: NSTextfield *textfield = [[NSTextField alloc] initWithFrame:NSMakeRect(5,5,150,20)]; [texField setStringValue:@"some text here"]; [textField setEditable:NO]; [textField setSelectable:NO]; [textField setBorde...

Force update of NSTextField

Hello, I have a NSTextField that gets updated when my app searches through an array: for (NSString *file in fileinDir) { processedFiles = processedFiles + 1; NSArray*filesinDevice = [fm contentsOfDirectoryAtPath:[[dict objectForKey:NSWorkspaceVolumeURLKey] path] error:nil]; [progressLabel setStringValue:[NSStr...

How can I force entry to complete in a NSTextField from a NSButton

I just noticed a problem when my user-interface is in a certain state. I have a table view with two columns both of which the user can enter data that is to be used later. There's also a button which acts upon the contents of the table view. The problem is if the user has entered new data in the column but has not yet exited the field ...

Cocoa (Snow Leopard) NSTextView's textStorage -setAttributes:range: removes characters!

I'm not sure what I'm doing wrong. I have a NSTextView and am registered as the delegate for its textStorage attribute. When I receive -textStorageDidProcessEditing:notification: I'm trying to apply attributes to ranges of characters within the text. It certainly does "something" to the characters, but not what I expect... they just d...

Send action from NSTextField when on key up instead of return.

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 UITe...

How to force an NSTextField to accept the text?

I have an NSTextField in a Preferences panel. It provides a field to enter a url in. However, if the user closes the Preferences panel after editing the text in the field, the new value does not get propagated to the User Defaults. This only happens after the user explicitly does Enter or Tab. This kind of makes the whole approach useles...