Loading...

xcode-users@lists.apple.com

[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: Document app: NSWindowController: Finding the NSWindow* for the controller window. Christiaan Hofman Sat Feb 11 03:00:19 2012

Have you connected the window outlet in your NIB?

Christiaan

On Feb 11, 2012, at 11:09, Clark Williams wrote:

> I have a document app.
> In the document .m file I create a subclassed NSWindowController called 
> CalculatorWindowController as follows:
> 
> - (void) makeWindowControllers
> {
>       // This works fine as the 'magic calculator' window appears and all 
> actions and outlets work fine.
>       if ( nil == sbcWC ) { // insure there is only one calc window open at a 
> time
>               sbcWC = [[CalculatorWindowController alloc] 
> initWithWindowNibName:@"CalculatorWindowController"];
>               [self addWindowController:sbcWC];
>       }
>       // Make more window controllers each from their own xnib files.
>       // (I actually create several window controllers but they don't need to 
> be resized.)
> }
> 
> Now I want to resize the sbcWC window when certain conditions happen and then 
> resize the window back again when those conditions no longer exist.
> To do this I believe I should be sending the following message:
> 
> [[sbcWC window] setFrame:binaryWindowFrameSize display:YES animate:YES];
> 
> But the value returned for [sbcWC window] is always nil. I cannot get the 
> window pointer to obtain the frame size nor to resize the window.
> 
> In the CalculatorWindowController the user can calculate how much of this 
> magic or that magic is necessary and mix the magic sources as necessary to 
> counteract spells, blunders and incoming holocausts, etc. Under certain 
> conditions the window should expand in width to show a larger output and then 
> collapse back to regular size when the conditions are removed.
> When the conditions exists I use a NSNotification indicating an "ACCOUNTING" 
> condition is necessary. When the conditions return to normal I use a 
> NSNotification indicating an "NON_ACCOUNTING" conditions. In the Document .m 
> file I have the following selector:
> 
> - (void) sbCalculatorCmdAccountingDeptDisplay:(NSNotification*)theData
> {
>    NSString *displayType = [NSString stringWithFormat:@"%@", [[theData 
> userInfo] objectForKey:ACCOUNTING_DEPT_DISPLAY_SB_CALCULATOR_CONTROLLER]];
>    NSLog ( @"Set calculator display %@", displayType );
>    if ( [displayType isEqualToString:@"ACCOUNTING"] ) {
>        [[sbcWC window] setFrame:accountingWindowFrameSize display:YES 
> animate:YES];
>    } else {
>        [[sbcWC window] setFrame:nonAccountingWindowFrameSize display:YES 
> animate:YES];
>    }
> }
> 
> The accountingWindowFrameSize is 120 pixels wider in size than the 
> nonAccountingWindowFrameSize.
> 
> The sbcWC does not change in size when either notification is received.
> When I breakpoint or NSLog the value for [sbcWC window] it is ALWAYS nil 
> (0x0).
> Which means that I cannot get a meaningful value for:
> [[sbcWC window] frame].size.width
> 
> How do I get the NSWindow* for sbcWC?
> 
> Any suggestions would be appreciated.
> TIA
> ClarkW
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list      ([EMAIL PROTECTED])
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/xcode-users/cmhofman%40gmail.com
> 
> This email sent to [EMAIL PROTECTED]


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      ([EMAIL PROTECTED])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/xcode-users/alexiscircle%40gmail.com

This email sent to [EMAIL PROTECTED]