display a text field?

  • I am trying to create a text field programmatically and to display it in the window. Here is the code

    -(void)awakeFromNib;
    {
        NSTextField *myTextField=[[NSTextField alloc] initWithFrame:NSMakeRect(100.0, 100.0, 80.0, 25.0)];
    }

    The code runs OK but no text field is shown in the window. What must I do to get it to display in the window?

    Thanks Bob

    __________________________________________________
    Do You Yahoo!?
    Tired of spam?  Yahoo! Mail has the best spam protection around
    http://mail.yahoo.com
  • Well all you've done is create a text field. It must be actually
    placed in the window to appear there. Try adding a second line of code
    along these lines:

    [[myWindow contentView] addSubview:myTextField];

    Mike.

    On 5 Nov 2007, at 14:40, Bob Ueland wrote:

    > I am trying to create a text field programmatically and to display
    > it in the window. Here is the code
    >
    > -(void)awakeFromNib;
    > {
    > NSTextField *myTextField=[[NSTextField alloc]
    > initWithFrame:NSMakeRect(100.0, 100.0, 80.0, 25.0)];
    > }
    >
    > The code runs OK but no text field is shown in the window. What must
    > I do to get it to display in the window?
    >
    > Thanks Bob
    >
    >
    >
    > __________________________________________________
    > Do You Yahoo!?
    > Tired of spam?  Yahoo! Mail has the best spam protection around
    > http://mail.yahoo.com
  • Thanks Mike,

    now it works

    ----- Original Message ----
    From: Mike Abdullah <cocoadev...>
    To: Bob Ueland <bobueland...>
    Cc: Apple Cocoa-Dev Mailing List <cocoa-dev...>
    Sent: Monday, November 5, 2007 3:47:51 PM
    Subject: Re: display a text field?

    Well all you've done is create a text field. It must be actually
    placed in the window to appear there. Try adding a second line of code

    along these lines:

    [[myWindow contentView] addSubview:myTextField];

    Mike.

    On 5 Nov 2007, at 14:40, Bob Ueland wrote:

    > I am trying to create a text field programmatically and to display
    > it in the window. Here is the code
    >
    > -(void)awakeFromNib;
    > {
    > NSTextField *myTextField=[[NSTextField alloc]
    > initWithFrame:NSMakeRect(100.0, 100.0, 80.0, 25.0)];
    > }
    >
    > The code runs OK but no text field is shown in the window. What must

    > I do to get it to display in the window?
    >
    > Thanks Bob
    >
    >
    >
    > __________________________________________________
    > Do You Yahoo!?
    > Tired of spam?  Yahoo! Mail has the best spam protection around
    > http://mail.yahoo.com

    __________________________________________________
    Do You Yahoo!?
    Tired of spam?  Yahoo! Mail has the best spam protection around
    http://mail.yahoo.com
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today