How to do something on launching of NSWindow?

Discussion in 'Mac Programming' started by newformac, Jun 3, 2011.

  1. macrumors regular

    #1
    Hi all,

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

    like this.

    Code:
    
    [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.
     
  2. jiminaus, Jun 3, 2011
    Last edited: Jun 3, 2011

    macrumors 65816

    jiminaus

    #2
    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?!
     
  3. macrumors regular

    #3
    can i call any function before this.
     
  4. macrumors 65816

    jiminaus

    #4
    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.
     
  5. macrumors regular

    #5
    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?
     
  6. macrumors 65816

    jiminaus

    #6
    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.
     
  7. macrumors regular

    #7
    thanks

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

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

Share This Page