PDA

View Full Version : How to do something on launching of NSWindow?




newformac
Jun 3, 2011, 03:23 AM
Hi all,

i have and main NSWindow here on button click i open another NSWindow

like this.



[NSApp beginSheet: Child_Window modalForWindow: Main_Window modalDelegate: nil didEndSelector: NULL contextInfo: nil];

int result = [NSApp runModalForWindow:Child_Window];
[Child_Window orderOut:nil];
[NSApp endSheet: Child_Window];



i want to set some text and label of child window before opening this,to display new text and label when its launched.

where i can do something when child window is launching.

thanks.



jiminaus
Jun 3, 2011, 03:29 AM
Why not just before calling beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:? Where are the outlets for the text and label? I'm presuming the text and label are in the sheet to be displayed, not in the window parenting the sheet.

BTW Is the code you posted above all in the same method?!

newformac
Jun 3, 2011, 03:34 AM
can i call any function before this.

jiminaus
Jun 3, 2011, 04:11 AM
Well not really any function. But you should be able to call setStringValue on an NSTextField object before it's on screen.

BTW. Please explain why you're calling both beginSheet and runModalForWindow on the same window. And where are orderOut and endSheet calls happening? The code you posted doesn't make much sense.

newformac
Jun 3, 2011, 04:22 AM
this is commented now

//int result = [NSApp runModalForWindow:Child_Window];

if i open an widnow on which i m using a image view browser ,how can initialize the path for images before opening this window?

jiminaus
Jun 3, 2011, 04:44 AM
this is commented now

//int result = [NSApp runModalForWindow:Child_Window];

if i open an widnow on which i m using a image view browser ,how can initialize the path for images before opening this window?

Set up an outlet to the image browser somewhere. Then setup the image browser using the outlet just before beginSheet.

The normal place to put the orderOut and endSheet calls is in the actions attached to the button(s) inside the sheets. Well, not so normal for orderOut, that's normally in the didEndSelector:, but you're not using one, so you need to do it in the button's action.

newformac
Jun 3, 2011, 04:59 AM
Set up an outlet to the image browser somewhere. Then setup the image browser using the outlet just before beginSheet.

The normal place to put the orderOut and endSheet calls is in the actions attached to the button(s) inside the sheets. Well, not so normal for orderOut, that's normally in the didEndSelector:, but you're not using one, so you need to do it in the button's action.

thanks

please provide help for my previous thread also i m stuck again

http://forums.macrumors.com/showthread.php?p=12675673#post12675673