nstextfield

Use KVO for NSTextFields that are bound together

十年热恋 提交于 2019-11-29 14:36:58
问题 I'm having trouble getting KVO working with text fields that are bound together in a Cocoa app. I have gotten this to work when setting strings in NSTextFields with buttons but it is not working with bindings. As always, any help from Stack Overflow would be greatly appreciated. Purpose of my code is to: bind several text fields together when a number is input in one field, have the other fields automatically update observe the changes in the text fields Here's my code for MainClass which is

How do I enable spell checking within an NSTextField on Mac OS X?

假装没事ソ 提交于 2019-11-29 13:30:04
问题 I have an NSTextField that I would like to enable "as-you-type" spell checking. When I load my application I can do this from the Menu Bar > Edit > Spelling and Grammar > Check Spelling While Typing. I would like this option to be enabled by default. Within IB I can enable this for a NSTextView but I would like to use NSTextField for this part of the UI. Thank you. Update: Does anyone know if it is possible to programatically run the Menu Bar > Edit > Spelling and Grammar > Check Spelling

NSTextField not calling delegate when inside an NSTableCellView

╄→尐↘猪︶ㄣ 提交于 2019-11-29 10:49:56
I have a fairly vanilla Source List (dragged out from the Object Library) in my app, with an NSTreeController as its data source. I set the NSTextField inside the DataCell to be editable, but I want to be able to turn that off for some cells. The way I figured you would do this, is with a delegate for the NSTextField , but none of the delegate methods I've tried get called. Is there something I'm missing? I have the delegate set with an outlet in my XIB, and it happens to be the delegate to the owner NSOutlineView , as well, implementing both the NSOutlineViewDelegate and NSTextFieldDelegate

How to detect when NSTextField has the focus or is it's content selected cocoa

隐身守侯 提交于 2019-11-29 07:19:37
I have a NSTextField inside of a NSTableCellView, and I want an event which informs me when my NSTextField has got the focus for disabling several buttons, I found this method: -(void)controlTextDidBeginEditing:(NSNotification *)obj{ NSTextField *textField = (NSTextField *)[obj object]; if (textField != _nombreDelPaqueteTextField) { [_nuevaCuentaActivoButton setEnabled:FALSE]; [_nuevaCuentaPasivoButton setEnabled:FALSE]; [_nuevaCuentaIngresosButton setEnabled:FALSE]; [_nuevaCuentaEgresosButton setEnabled:FALSE]; } } but it triggers just when my textfield is begin editing as this says, I want

Can't change the mouse cursor of a NSTextField

烂漫一生 提交于 2019-11-29 05:08:19
I'm trying to change the mouse cursor of a NSTextField in a window sheet, loaded from a NIB. Following the documentation, I have subclassed NSTextField and implemented resetCursorRects . - (void) resetCursorRects { [self addCursorRect:[self bounds] cursor:[NSCursor pointingHandCursor]]; } This is never called. Not even after adding the following in the NSWindowViewController : - (void) windowDidLoad { [self.window invalidateCursorRectsForView:self.linkTextField]; } I also tried with a tracking area by adding the following in the NSTextField subclass: - (void) awakeFromNib { NSTrackingArea*

NSTextField enter to trigger action

我的未来我决定 提交于 2019-11-29 03:47:59
I've been looking all over for a simple example of how to have an action (or button) be triggered when the enter key is hit in the text field. Should I subclass the text field? Would I need to set a delegate to call the action I need? Is there a way to catch the event in my main window controller class? If you could even just point me to the right direction that would be great. Thanks. To get action after you hit enter just write an IBAction in your window controller and connect to your text field. If you want more like your method should be called when you focus on text field and leave the

NSString boundingRectWithSize slightly underestimating the correct height - why?

情到浓时终转凉″ 提交于 2019-11-29 03:41:29
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 aligning to the bottom of my window despite efforts to manually move it back. Can anybody see what I'm doing wrong here? NSString *temp = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer vel felis nec massa ultricies blandit non id arcu. Sed enim est, facilisis a feugiat in, consectetur eget arcu. Aenean rutrum, lacus id euismod

NSTextField with “padding” on the right

牧云@^-^@ 提交于 2019-11-29 00:10:01
问题 I am trying to get the "remaining chars notice" to show up within my rounded NSTextField and I got it with two NSTextFields with help of the Interface Builder and it already looks like that: alt text http://jeenaparadies.net/t/s/Twittia-NSTextField1.png But when I write a little bit more it looks like that: alt text http://jeenaparadies.net/t/s/Twittia-NSTextField2.png The only thing I could think of is to subclass NSTextField and do something with it so it does not draw text under the number

Faking an NSTextField using an NSTextView to get nice coloring?

梦想与她 提交于 2019-11-28 23:16:47
问题 Trying to change the selected text background color for an NSTextField (we have a dark UI, and selected text background is almost the same as the text itself), but only NSTextView seems to allow us to change this. So we're trying to fake an NSTextField using an NSTextView, but can't get text scrolling to work the same. The closest we get is with this code: NSTextView *tf = [ [ NSTextView alloc ] initWithFrame: NSMakeRect( 30.0, 20.0, 80.0, 22.0 ) ]; // Dark UI [tf setTextColor:[NSColor

can't edit NSTextField in sheet at runtime

核能气质少年 提交于 2019-11-28 22:13:31
问题 When clicking on a button, I'd like to display a sheet with an email+password prompt with options to save and cancel. The UI is all set up, the actions are in place, and the sheet appears and cancels as expected. The problem is that I can't edit either of the NSTextFields at runtime; they appear to disabled, and the OS error sound plays on every key press when the sheet is open. I read on SO that UIActionSheet is appropriate, but this is not an iOS app. The textfields are enabled, and had