my preferences sheet appears under XCode not under the app ...

  • when it is the first run of my app, i force the app to open the preferences
    sheet like that :

      def awakeFromNib()
        puts "@isFirstRun = #{@isFirstRun}"
        if @isFirstRun
          @prefs = Preferences.new
          showPreferences( @mainWindow )
          @prefs.save
        end
    [...]

    however in that circumstance (first run) the sheet appears under an XCode
    window NOT under the mainWindow of my app.
    i do have the same result passing nil instead of @mainWindow to
    showPreferences

    the "normal" way (working) to open this sheet :
      def showPreferences( notification )
        NSApp.beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo(
    @panelWindow, @mainWindow, self, :prefsDidEndSheet_returnCode_contextInfo,
    nil )
      end

    is it possible to avoid that ?

    --
    yvon
  • On 9/2/07, Yvon Thoraval <yvon.thoraval...> wrote:
    > when it is the first run of my app, i force the app to open the preferences
    > sheet like that :
    >
    > def awakeFromNib()
    > puts "@isFirstRun = #{@isFirstRun}"
    > if @isFirstRun
    > @prefs = Preferences.new
    > showPreferences( @mainWindow )
    > @prefs.save
    > end
    > [...]
    >
    > however in that circumstance (first run) the sheet appears under an XCode
    > window NOT under the mainWindow of my app.

    I would guess that Ruby is doing something strange here since your
    application shouldn't have access to windows from Xcode as possible
    targets for a sheet, etc.

    > is it possible to avoid that ?

    Use objective-c maybe... I mean talk about losing on of the nice
    aspects of the language with something like
    "NSApp.beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo(...args...)"

    =P

    -Shawn
  • On 2-Sep-07, at 11:51 AM, Yvon Thoraval wrote:

    > when it is the first run of my app, i force the app to open the
    > preferences
    > sheet like that :
    >
    > def awakeFromNib()
    > puts "@isFirstRun = #{@isFirstRun}"
    > if @isFirstRun
    > @prefs = Preferences.new
    > showPreferences( @mainWindow )
    > @prefs.save
    > end
    > [...]
    >
    >

    The trick about awakeFromNib is that it is called just before the
    window is shown. This is very useful as it allows you to change
    aspects of the window's content before it is shown. However it means
    that you can't attach a sheet to the window, as you can't attach a
    sheet to a window that is not visible.

    On a side note, I don't think that a preferences window should never
    be displayed as a sheet as there usually is no reason why it should
    block the user from using the main window.

    Cheers, Patrick
previous month september 2007 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
Go to today