 |
 |
Accessing NSWindow functions through NSDocument...
|
 |
|
 |
|
Forum Regular
Join Date: Jul 2002
Location: Los Angeles, CA
Status:
Offline
|
|
I'm making a MUD client that treats each connection as a seperate document. However, problems arise in that several functions belong to NSWindow, and I cannot access these through the MyDocument source file. Would I use super? Or something else? Anyone have an idea?
|
|
I'm a bad...motherf%#!ing DJ
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
You should direct a message to whatever object you want to perform that method. If you want a window to do something, you send a message to that window. Sending a message to super would be wrong if you're an NSDocument subclass and you want an NSWindow method--because super is the calling object.
I'm not entirely sure that I know what you're looking for, but you can get an array of window controllers for a given document with the -windowControllers method. Hopefully that puts you somewhere in the right direction.
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Apr 2001
Location: Long Beach, CA
Status:
Offline
|
|
If each Document only accesses one window, then you can make add a pointer to your document that points to the window. Set it early on (like during initialization). Then, you always have easy access to that window. Document function calls that need to be redirected to the window can be done quite easily at that point.
|

ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Jan 2001
Status:
Offline
|
|
By default, if you use PB to create a cocoa doc-based app, MyDocument already has an outlet called "window" -- just send messages to that guy...
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Apr 2001
Location: Long Beach, CA
Status:
Offline
|
|
Originally posted by 00101001:
By default, if you use PB to create a cocoa doc-based app, MyDocument already has an outlet called "window" -- just send messages to that guy...
Ooh Cool! I was close.
Whether or not this is useful I think depends on how many windows are being used. If there is one window for multiple documents, this may not work. Idunno though; I haven't tried this type of structure.
|

ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jul 2002
Location: Los Angeles, CA
Status:
Offline
|
|
My program has a window for each document, so this method will work for me...thanks guys!
|
|
I'm a bad...motherf%#!ing DJ
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jul 2002
Location: Los Angeles, CA
Status:
Offline
|
|
OK, I had been busy the past week so I couldn't try this until today. Project builder is giving me an error when I attempt to send to "window." I have tried both "window" and "[self window]" with no success in the Document class file. Any ideas?
|
|
I'm a bad...motherf%#!ing DJ
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Nov 2001
Status:
Offline
|
|
Originally posted by Seamus:
OK, I had been busy the past week so I couldn't try this until today. Project builder is giving me an error when I attempt to send to "window." I have tried both "window" and "[self window]" with no success in the Document class file. Any ideas?
The only outlet I can see is _window; however, this is a private variable and therefore it's not a wise idea to use it. You could if you really wanted to though. If you don't want to use a private ivar, you could try this (completely untested):
Code:
NSWindow *myWindow = [[[self windowControllers] objectAtIndex:0] window];
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Jan 2001
Status:
Offline
|
|
Originally posted by Seamus:
OK, I had been busy the past week so I couldn't try this until today. Project builder is giving me an error when I attempt to send to "window." I have tried both "window" and "[self window]" with no success in the Document class file. Any ideas?
Hmmm... i thought [self window] would be the way to go... but try this.
Create a new outlet in your MyDocument.h like myWindow or something
IBOutlet id myWindow;
then in your MyDocument.nib file (open in IB), drag a connection from File's Owner (which is really just a MyDocument object) to your window instance. then, in MyDocument, you can just send messages to myWindow.
this is off the top of my head... it should work though...
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|