Issue while calling run modal after showing a sheet

  • Hi All,

    I have a small requirement. I am calling a sheet in my code. I
    wanted the control to be in the same line until the sheet is closed.
    I have written the code in the following way. Doing this , i am
    unable to receive application events. Because , i have used  [NSApp
    runModalForWindow: myCustomDialog];. If i do not run the window as
    modal, the control is going to the next line.  Is there anyway i can :
    - call a sheet
    - have the control in the same line until the sheet is closed.
    - also able to perform actions on NSApp.

    - (void)showCustomDialog: (NSWindow *)window
    // User has asked to see the dialog. Display it.
    {
        if (!myCustomDialog)
            [NSBundle loadNibNamed: @"MyCustomDialog" owner: self];

        [NSApp beginSheet: myCustomDialog
                modalForWindow: window
                modalDelegate: nil
                didEndSelector: nil
                contextInfo: nil];

        [NSApp runModalForWindow: myCustomDialog];
        // Dialog is up here.
        [NSApp endSheet: myCustomDialog];
        [myCustomDialog orderOut: self];
    }

    thanks,
    Ramesh PVK
  • On 06/10/2006, at 2:19 PM, RameshPVK wrote:

    > Hi All,
    >
    > I have a small requirement. I am calling a sheet in my code. I
    > wanted the control to be in the same line until the sheet is closed.
    > I have written the code in the following way. Doing this , i am
    > unable to receive application events. Because , i have used  [NSApp
    > runModalForWindow: myCustomDialog];. If i do not run the window as
    > modal, the control is going to the next line.  Is there anyway i can :
    > - call a sheet
    > - have the control in the same line until the sheet is closed.
    > - also able to perform actions on NSApp.

    No. Why do you really want to?

    Just use didEndSelector and put the code you want to run after the
    sheet has been dismissed in the didEndSelector method.

    - Chris
  • On 06/10/2006, at 2:19 PM, RameshPVK wrote:
    >
    >
    >> Hi All,
    >>
    >> I have a small requirement. I am calling a sheet in my code. I
    >> wanted the control to be in the same line until the sheet is closed.
    >> I have written the code in the following way. Doing this , i am
    >> unable to receive application events. Because , i have used  [NSApp
    >> runModalForWindow: myCustomDialog];. If i do not run the window as
    >> modal, the control is going to the next line.  Is there anyway i
    >> can :
    >> - call a sheet
    >> - have the control in the same line until the sheet is closed.
    >> - also able to perform actions on NSApp.
    >>
    >
    > No. Why do you really want to?
    >
    > Just use didEndSelector and put the code you want to run after the
    > sheet has been dismissed in the didEndSelector method.
    >
    > - Chris

    Thanks for the reply.
    Actually , i want to  provide a lookup kind of function, which will
    show sheet and return the selected value as return value of the
    function. This is a common function which will be used across many
    places. I do not want to use delegation pattern also.
  • On Oct 5, 2006, at 9:32 PM, RameshPVK wrote:

    > Actually , i want to  provide a lookup kind of function, which will
    > show sheet and return the selected value as return value of the
    > function. This is a common function which will be used across many
    > places. I do not want to use delegation pattern also.

    Then you could run the run loop by repeatedly calling -[NSApplication
    nextEventMatchingMask:...] until the -sheetDidEnd:... method is
    called and is returned. But you can't run a sheet as application-modal.

    Nick Zitzmann
    <http://www.chronosnet.com/>
previous month october 2006 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today