Question

I've created a sheet which I would like to display various messages while the program is doing data crunching. The sheet opens and closes correctly and I have a Text Label on the sheet which is connected to my main controller (the owner of the sheet) with an IB Outlet.

The Nib loads correctly, open and closes correctly, but the static text label is never updated. The connected IBOutlet was defined this way:

IBOutlet id mySheetText;

The call I am using to try and modify the text on the sheet is this:

[mySheetText setStringValue:@"Some text message..."];

This format works fine if the Label is in the main window, but does nothing if the Label is on the sheet.

All the connections in IB appear to be correct. I'm sure that I'm missing something very simple, and i'm guessing that it has something to do with the fact that the sheet is a different "window" than the main window, but I can't seem to find anything in the docs to point me in the right direction.

Incidentally, here is the way I connected the sheet...

NSWindow *mySheet;

@property (assign) IBOutlet NSWindow *mySheet;
@synthesize mySheet;

...and opened it:

if (!serverSyncSheet) {
    [NSBundle loadNibNamed:@"mySheetNibFile" owner:self];
}

[NSApp beginSheet: self.mySheet
   modalForWindow: [[NSApp delegate] mainWindow]
    modalDelegate: self
   didEndSelector: NULL
          contextInfo: NULL];

Any ideas?

* EDIT *

Ok, so it turns out that I am partially correct. If I attempt to read the text value, it turns out that it IS setting it to the correct text, but the sheet is not being updated to DISPLAY the change. I suspect that I need to tell the window to redraw... never done that before. Back to the docs to see if I can find it. If anyone knows the method to call, let me know. :) Thanks!

Was it helpful?

Solution

Well, my suspicions were correct... it was something simple.

I just had to redraw the window:

[mySheet display];

Doh! :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top