Displaying controls, created in ur class

Discussion in 'Mac Programming' started by ASPCartman, Dec 10, 2009.

  1. ASPCartman macrumors newbie

    Joined:
    Dec 10, 2009
    #1
    Newbie here =).
    Need help. I create, for example, NSButton in my class. How to show it on form?
    What i need is to write a puzzle-game app (box of buttons without one, so u move them around to build image). I can make lots_of_buttons in interface builder, but what if i wish to dynamicly make more of them while app runs?

    In delphi, for example, it looks like this:
    Code:
     button=TButton.Create(panel1);
     button.Parent=panel1;
    Where "panel1" is some panel placed on a form.

    Help, please. Reading docs and googling didn't help - seems like it's too obvius to talk about it.
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    Code:
    NSButton *button = [[NSButton alloc] initWithFrame:yourFrame];
    [[window contentView] addSubview:button];
     
  3. ASPCartman thread starter macrumors newbie

    Joined:
    Dec 10, 2009
    #3
    kainjow
    THX. But what is "urframe"? Xcode says it must be some "NSRectFrame" - what is this? o_O

    For example i need to create button in box:

    Code:
    NSButton *button = [[NSButton alloc]initWithFrame:???];
    [[box contentView] addSubview:button];
    If i replace initWithFrame with init - nothin is hapenning.
     
  4. ASPCartman thread starter macrumors newbie

    Joined:
    Dec 10, 2009
    #4
    Nevermind, googled it down.
    Other question - how to init, for example, bevel button?
     
  5. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #5

Share This Page