Mac Displaying controls, created in ur class

ASPCartman

macrumors newbie
Original poster
Dec 10, 2009
3
0
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.
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
5
Code:
NSButton *button = [[NSButton alloc] initWithFrame:yourFrame];
[[window contentView] addSubview:button];
 

ASPCartman

macrumors newbie
Original poster
Dec 10, 2009
3
0
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.
 

ASPCartman

macrumors newbie
Original poster
Dec 10, 2009
3
0
Nevermind, googled it down.
Other question - how to init, for example, bevel button?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.