Search Results

Search found 61 results on 3 pages for 'nstextfield'.

Page 1/3 | 1 2 3  | Next Page >

  • Subclassing an NSTextField

    - by Hooligancat
    Given all the complex things I seem to cover every day, this appears to be a "what the heck am I doing wrong that seems to simple?" scenario! I would like to subclass an NSTextField to change the background color and text color. For simplicity sake (and to help anyone who hasn't ever subclassed anything before), here is the example of my (simplified) subclass MyNSTextFieldSubclass... Step 1: Create the subclass file: First the header file @interface MyTextFieldSubclass : NSTextField { } @end And the method file @implementation MyTextFieldSubclass -(NSColor *)backgroundColor { return [NSColor redColor]; } -(NSColor *)textColor { return [NSColor yellowColor]; } @end Step 2: Drag an NSTextField to a window in Interface Builder, select the Identity tab in the inspector and select the class MyTextFieldSubclass Step 3: Save the IB file, build and run the application Problem When I run the build, the text field does not reflect the color subclassing. However, I know the subclass is being called because if I add the following method, it gets called on text changes. -(void)textDidChange:(NSNotification *)notification { NSLog(@"My text changed"); } So why does the color change not occur on the text fields? I know that I can set the color in IB, but for anyone who has dealt with a lot of UI elements that all need the same styling, subclassing makes life way, way easier. Ironically, I have never had to subclass an NSTextField before and this one has me stumped. As usual, any and all help very much appreciated. I'm sure it will turn out to be a "Doh!" moment - just cant see the wood for the trees right now (plus I'm exhausted from watching too much World Cup Football early in the morning which never helps).

    Read the article

  • how to get NSTextField in custom NSFormatter class

    - by Amit
    i am new to cocoa and objective-c and creating small application having few NStextFields on the window.I have create custom NSformatter to validate the inputs,at some instance i want to get the NStextField within my custom NSformatter to change its backcolor to red to notify user for wrong input value.I didn't getting how to get the currently selected/focused NStextfield for which i want to change backcolor.

    Read the article

  • NSTextField doesn't display text

    - by Alexsander Akers
    The NSTextField has a superview and a frame. It is fully visible and has the following declaration: - (id) initWithFrame: (NSRect) frameRect { if ((self = [super initWithFrame: NSMakeRect(0, 0, 300, 20)])) { label = [[NSTextField alloc] initWithFrame: NSMakeRect(47, 1, 233, 18)]; [[label cell] setAllowsUndo: NO]; [[label cell] setLineBreakMode: NSLineBreakByTruncatingMiddle]; [[label cell] setScrollable: NO]; [label setBezeled: NO]; [label setBordered: NO]; [label setDrawsBackground: NO]; [label setEditable: NO]; [label setFont: [NSFont menuFontOfSize: 14.0f]]; [label setSelectable: NO]; [label setTextColor: [NSColor textColor]]; [self addSubview: label]; NSLog(@"%@", NSStringFromRect([label visibleRect])); } return self; }

    Read the article

  • NSTextField autocomplete

    - by Rasmus Styrk
    Does anyone know of any class or lib that can implement autocompletion to an NSTextField? I'am trying to get the standard autocmpletion to work but it is made as a synchronous api. I get my autocompletion words via an api call over the internet. What have i done so far is: - (void)controlTextDidChange:(NSNotification *)obj { if([obj object] == self.searchField) { [self.spinner startAnimation:nil]; [self.wordcompletionStore completeString:self.searchField.stringValue]; if(self.doingAutocomplete) return; else { self.doingAutocomplete = YES; [[[obj userInfo] objectForKey:@"NSFieldEditor"] complete:nil]; } } } When my store is done, i have a delegate that gets called: - (void) completionStore:(WordcompletionStore *)store didFinishWithWords:(NSArray *)arrayOfWords { [self.spinner stopAnimation:nil]; self.completions = arrayOfWords; self.doingAutocomplete = NO; } The code that returns the completion list to the nstextfield is: - (NSArray *)control:(NSControl *)control textView:(NSTextView *)textView completions:(NSArray *)words forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(NSInteger *)index { *index = -1; return self.completions; } My problem is that this will always be 1 request behind and the completion list only shows on every 2nd char the user inputs. I have tried searching google and SO like a mad man but i cant seem to find any solutions.. Any help is much appreciated.

    Read the article

  • How to add data from an NSTextField to a Core Data Attribute without having to press Return or Tab a

    - by roy-fleming
    I use a sheet with 3 NSTextFields and a Cancel- and OK-Button to edit the attributes of a Core Data Entity. The text entered in the NSTextFields is only updated in the Core Data Entity if i press Tab or Return after writing in the NSTextField or if i focus another NSTextField with the mouse. If i just enter text in an NSTextField and press the OK-Button the entered text is lost. Is there some attribute i can set in Interface Builder to change this NSTextField behaviour?

    Read the article

  • NSTextField (Label) Attributed Text: Select

    - by huntaub
    I have a NSTextField Label that has attributed text in it. The color and size are different from the defaults. (The text is a bit larger and green) Now, I need to be able to select the text in the label so as the click the hyperlinks embedded in the attributed text. This works fine; however, when selecting the text the format of the text reverts back to the defaults (a smaller, black font). Is there anyway to stop this behavior so that my styling is preserved when the user clicks (selects text) on a Label?

    Read the article

  • how to show avg of employees salary in a NSTextField using NSArrayController and cocoa bindings

    - by Miraaj
    Hi all, I am new to cocoa bindings so I tried to make a simple application which will simply calculate avg of employees salary and display it in a text field, using cocoa bindings. I followed these steps: Made the model class : Person with one property for now - @property (readwrite, assign) int salary; In the application delegate class I initialized a mutable array : personArray with certain objects like this: Person *person1 = [[Person alloc] init]; person1.salary = 5000; Person *person2 = [[Person alloc] init]; person2.salary = 15000; Person *person3 = [[Person alloc] init]; person3.salary = 7000; Person *person4 = [[Person alloc] init]; person4.salary = 9000; Person *person5 = [[Person alloc] init]; person5.salary = 11000; personArray= [[NSMutableArray alloc] initWithObjects:person1, person2, person3, person4, person5,nil]; In IB I dropped a NSArrayController object, set its mode as Class - Person, added key salary in attribute pane. Then in bindings pane, binded contents array to ApplicationDelegate class with model key path set to self.personArray. Dropped a NSTextField on window. Binded its value to ArrayController object. Assigned controller key as - arrangedObjects. Assigned Model key path to @avg.salary When I executed the application I found no value being displayed in the text field. Can anyone suggest me where I may be wrong? Thanks, Miraaj

    Read the article

  • using a custom nstextfieldcell in an nstextfield

    - by joels
    I have a custom nstextfieldcell. I thought I could drag a textfield to a xib and click on it's cell, then change the cell's class to my custom class.That doesn't work. Also, I thought I could drag the custom cell from the library (i made a plugin) over the textfield and it would set the new cell like in a table. That doesn't work either. Does anybody know how to use a custom cell in a textfield?

    Read the article

  • Trying to create link with NSTextField

    - by Chris
    I'm using this category (is that right?) http://www.nightproductions.net/references/dsclickableurltextfield_reference.html#setAttributedStringValue to implement clickable textfields. I've imported the header file in my controller class and set it's attributed string value like this NSAttributedString* str = [[NSAttributedString alloc] initWithString:@"http://www.yahoo.com"]; [url setAttributedStringValue:(NSAttributedString *)str]; [str release]; The text field is not selectable and not editable. The text field value is set but it's not clickable and it's not a link. Thanks in advance.

    Read the article

  • NSTextField enter to trigger action

    - by Chris
    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.

    Read the article

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

    - by Luke
    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.

    Read the article

  • How do I enable spell checking within an NSTextField?

    - by Luke
    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.

    Read the article

  • How to limit NSTextField text length and keep it always upper case?

    - by carlosb
    Need to have an NSTextField with a text limit of 4 characters maximum and show always in upper case but can't figure out a good way of achieving that. I've tried to do it through a binding with a validation method but the validation only gets called when the control loses first responder and that's no good. Temporarly I made it work by observing the notification NSControlTextDidChangeNotification on the text field and having it call the method: - (void)textDidChange:(NSNotification*)notification { NSTextField* textField = [notification object]; NSString* value = [textField stringValue]; if ([value length] > 4) { [textField setStringValue:[[value uppercaseString] substringWithRange:NSMakeRange(0, 4)]]; } else { [textField setStringValue:[value uppercaseString]]; } } But this surely isn't the best way of doing it. Any better suggestion?

    Read the article

  • How do I send the mutable string to the NSTextField properly?

    - by Merle
    So I have all this code that I have debugged and it seems to be fine. I made a mutable string and for some reason I can not get it to be displayed on my label. the debugger says "2010-04-22 22:50:26.126 Fibonacci[24836:10b] * -[NSTextField setString:]: unrecognized selector sent to instance 0x130150" What is wrong with this? When I just send the string to NSLog, it comes out fine. here's all my code, any help would be appreciated. "elementNum" is a comboBox and "display" is a Label. Thanks #import "Controller.h" @implementation Controller - (IBAction)computeNumber:(id)sender { int x = 1; int y = 1; NSMutableString *numbers = [[NSMutableString alloc] init]; [numbers setString:@"1, 1,"]; int num = [[elementNum objectValueOfSelectedItem]intValue]; int count = 1; while (count<=num) { int z = y; y+=x; x=z; [numbers appendString:[NSString stringWithFormat:@" %d,", y]]; count++; } [display setString:numbers]; NSLog(numbers); } @end `

    Read the article

  • NSTextField is not changing value?

    - by Curnelious
    Migrating from iOS , i might do something stupid ,but after 1 hour i couldn't change the text in a NSTextField. Yes, its connected with an outlet, and i have tried to remove and add a few of them to the costume view, by choosing the xib file,drag a line from the NSTextField to the class than created this: @property (strong) IBOutlet NSTextField *ProgressLabel; I can see on the screen the label ,but it wouldn't change : NSLog(@"starting "); [self.ProgressLabel setStringValue:@"1 2 4"]; I keep seeing a "label" on screen..

    Read the article

  • How does an NSTextField know that it's value has changed?

    - by Brian Postow
    I have a textfield that can either be edited by hand, or set through another control. (It's a page number, so you can jump to page 16 by typing in 16, or you can page up and down with the next/prev buttons) I have the value of the text field bound to an int page variable. It seems to work correctly, when you type a page number in, it jumps, when you page up and down, the page number in the text box changes appropriately. However, at some level, when I page up and down, the text box doesn't seem to know that it's value has changed, because if I type 1 it doesn't do anything. It doesn't call the bound set-method or anything. It looks like the textfield is thinking "I'm already 1, so I don't need to do anything." Even though it was 5 because I hit next 4 times. If I type an number other than 1, it goes there. If I THEN type 1, it goes to page 1, because now it thinks it's on that other page. The problem seems to be that I'm changing the value of the textfield programatically, but some part isn't getting the message. Does this seem like a reasonable explanation? And either way, any ideas on what's causing it? thanks

    Read the article

  • Binding the textDidChange event on a NSTextField to a MacRuby delegate

    - by kolrie
    I have a NSTextField within a Window and I created a very simple MacRuby delegate: class ServerInputDelegate attr_accessor :parent def textDidChange(notification) NSLog notification.inspect parent.filter end end And I have tried setting the control's delegate: I have tried setting the Window and every other object I could think of to this delegate. I have also tried setting it to other delegates (application for instance) and events like applicationDidFinishLaunching are being properly triggered. Is there any trick I am missing in order for this event to be triggered every time the contents of this NSTextField changes?

    Read the article

  • focus a NSTextField

    - by Jeena
    I have a NSTextField and I want to set its content if I klick on a button and than set the cursor on this textfield at the end of the text so if someone klicks the button he could just begin to type. Until now I use [NSTextField selectText] it selects this textfield but it selects the whole text so if someone just begins to type he'd lose all the text which alread is in the textfield.

    Read the article

  • Manipulating a NSTextField via AppleScript

    - by Garry
    A little side project I'm working on is a digital life assistant, much like project JARVIS. What I'm trying to do is speak to my mac, have my words translated to text and then have the text interpreted by my program. Currently, my app is very simple, consisting of a single window containing a single wrapped NSTextView. Using MacSpeech Dictate, When I say the custom command "Jeeves", MacSpeech ensures that my app is frontmost, highlights any text in the TextField and clears it, then presses the Return key to trigger the textDidEndEditing method of NSTextField. This is done via Applescript. MacSpeech then switches to dictation mode and the next sentence I say will appear in the NSTextField. What I can't figure out is how to signify that I have finished saying a command to my program. I could simply say another keyword like "execute" or something similar that would send an AppleScript return keystroke to my app (thereby triggering the textDidEndEditing event) but this is cumbersome. Is there a notification that happens when text is pasted into a NSTextField? Would a timer work that would fire after maybe three seconds once my program becomes frontmost (three seconds should be sufficient for me to say a command)? Thanks,

    Read the article

  • NSStepper ignores current NSTextField value

    - by JanX2
    I have the same initial problem as described in Integrate NSStepper with NSTextField: I need to have a NSTextField working with a NSStepper as being one control so that I can edit an integer value either by changing it directly on the text field or using the stepper up/down arrows. Using bindings as commented on by carlosb results in a usable UI. However, in the initial question carlosb describes the following: Problem is that if I edit the text field then click the stepper again it will forget about the value I manually edited and use the stepper's internal value. This is why I am posting a variation on this question again. carlosb's use of bindings doesn't solve this problem. This happens in both the current project I am working on and a test project I have created. The test project can be found at GitHub. You can download it there (even without git) via the "Download Source" button in the top right. Is there a clean way to solve this issue?

    Read the article

  • Adding an NSTextField as a subview

    - by Kenny
    I'm trying to add an NSTextField as a subview of a custom view class I have (which subclasses NSView), and then make the text field the first responder. This works fine... the text field shows up and I can start typing in it. However, any mouse events in the text field seem to fall through to its superview. For example, I can't see the mouse cursor when I hover over the text field, and when I click anywhere in the text field, it attempts to resign firstResponder status instead of letting me select text within the text field. I'm not overridding hitTest or anything weird like that, and I only have one window, which is definitely the key window. Any ideas? Thanks in advance! :-)

    Read the article

  • NSTextField and hidden property

    - by jasonbogd
    Hi, I have an NSTextField that I hide when the user presses a button. I hide the text field using [textField setHidden:YES]; The problem is that is the user is typing in the text field (i.e. the text field is first responder) and the user presses the return key (which is the key equivalent for the button that hides the text field) the user can keep typing in the text field even though its not visible. How do I correctly remove a text field without actually deallocating it? Thanks.

    Read the article

1 2 3  | Next Page >