Subclassing NSTextField

Discussion in 'Mac Programming' started by ruhi, Aug 4, 2009.

  1. ruhi macrumors member

    Joined:
    Jun 17, 2009
    #1
    Hello,

    I have made a subclass of NSTextField and trapped all keyup events on the textfield that my nib file has.

    Problem is when i try to set any text into the text field in one of the button click event.

    Code:
    -(IBAction)setData: (id)sender
    {
           [mytextField setStringValue:str];
    }
    i cannot see any string in my textfield. Why is this so? :confused::confused:

    Thanks,
    Ruhi.
     
  2. ritsard macrumors regular

    ritsard

    Joined:
    Jun 18, 2009
    Location:
    SF Bay Area, CA
    #2
    so you're using the keyEvent to check for key strokes? What are you trying to achieve? What button do you click and why do you do it that way?
     
  3. SRossi macrumors regular

    Joined:
    May 27, 2009
    Location:
    Glasgow, Scotland
    #3
    I've had a look on google for you and people are saying that you need to update your view after changing the values. Try this and see.

    Stephen
     
  4. ruhi thread starter macrumors member

    Joined:
    Jun 17, 2009
    #4
    subclassing NSTextField

    Thanks for the concern.

    But i got the solution now.

    I just have to write [self setStringValue:mad:"test"] after setting the class of textfield as my class which is subclass of NSTextField.

    Thanks,
    ruhi.
     

Share This Page