Re: Windows and nibs and dialogs, oh my!
Re: Windows and nibs and dialogs, oh my!
- Subject: Re: Windows and nibs and dialogs, oh my!
- From: Steven Degutis <email@hidden>
- Date: Tue, 2 Mar 2010 21:53:08 -0500
Few simple steps:
(1) Create a subclass of NSWindowController and override -init to call
super's -initWithWindowNibName:, passing something like @"MyWindow"
(2) Create a XIB file with the filename called MyWindow
(3) Change File's Owner to your recent subclass
(4) Connect the -window outlet of your subclass to the NSWindow in the XIB
file
(5) Instantiate your subclass somewhere and either access -window directly
or call -showWindow: (which is what I usually do)
-Steven
On Tue, Mar 2, 2010 at 9:13 PM, William Squires <email@hidden>wrote:
> Please help, I'm still a bit fuzzy on how to open a window in Cocoa/ObjC. I
> realize there's a correlation between a nib, the window you design(ed) in
> IB, and the .h/.m files for the controller class, but how do you actually
> USE this stuff? i.e. If I wanted to make a window in REALbasic, I would
> design the window's UI, put in a publicly accessible Display() method that
> did something like:
>
> Public Sub Display()
> // Setup control's states based on available info (this window's class'
> properties)
> Me.Setup()
>
> // This is a modal window to allow the player to roll a new
> player-character
> Me.ShowModal()
> End Sub
>
> Then, somewhere else, I would do:
>
> Dim w As wndRollNewPC
> Dim theNewPC As PlayerChar
>
> theNewPC = nil
> w = New wndRollNewPC()
> w.DefaultPlayerName = "<untitled PC>"
> w.UseDefaultRules = True
> w.Display()
> theNewPC = w.NewPC
> w = nil
> If (theNewPC = nil) Then
> // Player somehow aborted
> Exit Sub
> End If
> ...
>
>
> And the call "w.Display() would make the window visible and frontmost (or,
> in Cocoa terms, it would load the nib, then - somehow - make it (the window,
> not the nib!) visible, and set one of the controls to be FirstResponder. It
> would also hook up the FilesOwner proxy object reference.)
> What I want to know is how to get this bit of magic to work? Am I going to
> have to chant arcane phrases over my keyboard while moving my mouse just so?
> :) This gets even more confusing on the iPhone, BTW.
>
>
> A compiler is a tool for turning source code into error messages;
> generating machine language bytes is just a fortuitous by-product!
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
--
Steven Degutis
http://www.thoughtfultree.com/
http://www.degutis.org/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden