Toggling Visibility for NSPanel

  • I've spent a decent amount of time trying to get a panel to close
    programatically but the solution escapes me. I'm sure this is a simple
    thing but [utilityPanel setVisible: NO] gives a warning when I compile
    and then I get an error 'selector not recognized' when I actually run
    my app and try to close my panel.

    If I have a panel with an outlet to it in my AppController object,
    what message can I send the panel to close/hide it? And how can I show
    it when I want to make it visible again?

    Thanks,
    Jason
  • On Oct 24, 2007, at 9:38 PM, Jason Barker wrote:

    > I've spent a decent amount of time trying to get a panel to close
    > programatically but the solution escapes me. I'm sure this is a simple
    > thing but [utilityPanel setVisible: NO] gives a warning when I compile
    > and then I get an error 'selector not recognized' when I actually run
    > my app and try to close my panel.

    -isVisible and -setVisible: are for views, not windows.

    > If I have a panel with an outlet to it in my AppController object,
    > what message can I send the panel to close/hide it?

    -close or -orderOut:.

    > And how can I show
    > it when I want to make it visible again?

    -makeKeyAndOrderFront: unless you don't want it to be the key view.

    Nick Zitzmann
    <http://www.chronosnet.com/>
  • I tried -close which works (but it doesn't show up in the code
    completion list). Both -orderOut and -makeKeyAndOrderFront yield the
    'selector not recognized' error. Is there something else I can try?

    Thanks,
    Jason

    On 10/24/07, Nick Zitzmann <nick...> wrote:
    >
    > On Oct 24, 2007, at 9:38 PM, Jason Barker wrote:
    >
    >> I've spent a decent amount of time trying to get a panel to close
    >> programatically but the solution escapes me. I'm sure this is a simple
    >> thing but [utilityPanel setVisible: NO] gives a warning when I compile
    >> and then I get an error 'selector not recognized' when I actually run
    >> my app and try to close my panel.
    >
    > -isVisible and -setVisible: are for views, not windows.
    >
    >> If I have a panel with an outlet to it in my AppController object,
    >> what message can I send the panel to close/hide it?
    >
    > -close or -orderOut:.
    >
    >> And how can I show
    >> it when I want to make it visible again?
    >
    > -makeKeyAndOrderFront: unless you don't want it to be the key view.
    >
    > Nick Zitzmann
    > <http://www.chronosnet.com/>
    >
    >
    >
    >
    >
  • On Oct 24, 2007, at 10:29 PM, Jason Barker wrote:

    > I tried -close which works (but it doesn't show up in the code
    > completion list). Both -orderOut and -makeKeyAndOrderFront yield the
    > 'selector not recognized' error. Is there something else I can try?

    Both of those take a sender argument, that is, [panel
    makeKeyAndOrderFront:self];

    Check the docs for NSWindow, from which NSPanel inherits all of these
    interesting methods.

    -> jp
  • On Oct 24, 2007, at 11:29 PM, Jason Barker wrote:

    > I tried -close which works (but it doesn't show up in the code
    > completion list). Both -orderOut and -makeKeyAndOrderFront yield the
    > 'selector not recognized' error. Is there something else I can try?

    It's -orderOut:, not -orderOut. Notice the :. NSPanel inherits from
    NSWindow, so don't forget to check the documentation of a class'
    superclasses.

    Nick Zitzmann
    <http://www.chronosnet.com/>
  • On Oct 24, 2007, at 8:38 PM, Jason Barker wrote:

    > I've spent a decent amount of time trying to get a panel to close
    > programatically but the solution escapes me. I'm sure this is a simple
    > thing but [utilityPanel setVisible: NO] gives a warning when I compile
    > and then I get an error 'selector not recognized' when I actually run
    > my app and try to close my panel.
    >
    > If I have a panel with an outlet to it in my AppController object,
    > what message can I send the panel to close/hide it? And how can I show
    > it when I want to make it visible again?

    Simple. Just use [myPanel setIsVisible:(BOOL)];

    Russ
previous month october 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 31        
Go to today