Prevent NSWindow from hiding with app

  • Is it possible to prevent a window from hiding when NSApp is hidden, so it
    always stays on screen? I only want the menu bar to go away.
  • Am 25.03.2010 um 19:10 schrieb fabian:

    > Is it possible to prevent a window from hiding when NSApp is hidden, so it
    > always stays on screen? I only want the menu bar to go away.

    Do you really mean "hidden" (like Command-H) or do you mean "not the frontmost application"? If the latter is the case, take a look at NSWindow's setLevel: method.

    Cheers,

    Knut
  • On Mar 25, 2010, at 1:10 PM, fabian wrote:

    > Is it possible to prevent a window from hiding when NSApp is hidden, so it
    > always stays on screen? I only want the menu bar to go away.

    That doesn't make any sense.

    You "want the menu bar to go away"?  So there would be no menu bar?  Or so that some other app's menu bar would be showing but your app's window would be frontmost?

    Whatever you might call that, that's not hiding the application.  If you want to hide the menu bar, then hide the menu bar.  If you want one of your windows to remain floating above other applications, then you can do that.

    When I as a user hide an application, though, it had better go away.  I don't care what reasons you think you have, but you don't get to decide that your application should continue to present its GUI when the user has chosen to hide it.

    Regards,
    Ken
  • Hi Fabian

    > Is it possible to prevent a window from hiding when NSApp is hidden, so it
    > always stays on screen? I only want the menu bar to go away.

    Simply uncheck the "Hide on Deactivate" option for the window in IB.

    Joanna

    --
    Joanna Carter
    Carter Consulting
  • Hi Joanna, Ken, Knut,

    Thanks, but the "Hide on Deactivate" option only works when NSApp is
    deactived, not hidden (as in Command+H). The window I want to stay on screen
    is a system wide icon window like the one you see when adjusting screen
    brightness, so it's most definitely the expected behavior from a user
    perspective.

    -F

    On Thu, Mar 25, 2010 at 7:30 PM, Joanna Carter <
    <cocoadev...> wrote:

    > Hi Fabian
    >
    >> Is it possible to prevent a window from hiding when NSApp is hidden, so
    > it
    >> always stays on screen? I only want the menu bar to go away.
    >
    > Simply uncheck the "Hide on Deactivate" option for the window in IB.
    >
    > Joanna
    >
    > --
    > Joanna Carter
    > Carter Consulting
    >
    >
  • Am 25.03.2010 um 19:44 schrieb fabian:

    > Thanks, but the "Hide on Deactivate" option only works when NSApp is
    > deactived, not hidden (as in Command+H). The window I want to stay on screen
    > is a system wide icon window like the one you see when adjusting screen
    > brightness, so it's most definitely the expected behavior from a user
    > perspective.

    It is still unclear to me, what exactly you want to accomplish. Is your app notified in any way if it needs to display the window (say, by a keydown, like the brightness control you have mentioned)?

    Perhaps [NSApp activateIgnoringOtherApps: YES]; would be useful then? Again, I (we?) don't understand precisely what you actually want to do.

    Cheers,

    Knut
  • Sorry for being unclear. I want NSApp to behave normally, i.e. when the user
    hides it (with Command+H) the menu bar and all windows _except this one
    window_ should hide. I do know when this floating window is supposed to be
    on screen and when it's not; it's displayed for a few seconds in response to
    a hotkey - but I don't want to have to delay the hiding of NSApp until the
    window has been ordered out (if the user decides to hide it when the window
    is on screen). I hope this clarifies my goal.

    On Thu, Mar 25, 2010 at 8:37 PM, Knut Lorenzen <knut...> wrote:

    >
    > Am 25.03.2010 um 19:44 schrieb fabian:
    >
    >> Thanks, but the "Hide on Deactivate" option only works when NSApp is
    >> deactived, not hidden (as in Command+H). The window I want to stay on
    > screen
    >> is a system wide icon window like the one you see when adjusting screen
    >> brightness, so it's most definitely the expected behavior from a user
    >> perspective.
    >
    > It is still unclear to me, what exactly you want to accomplish. Is your app
    > notified in any way if it needs to display the window (say, by a keydown,
    > like the brightness control you have mentioned)?
    >
    > Perhaps [NSApp activateIgnoringOtherApps: YES]; would be useful then?
    > Again, I (we?) don't understand precisely what you actually want to do.
    >
    > Cheers,
    >
    > Knut
    >
    >
  • Am 25.03.2010 um 20:52 schrieb fabian:

    > Sorry for being unclear. I want NSApp to behave normally, i.e. when the user
    > hides it (with Command+H) the menu bar and all windows _except this one
    > window_ should hide.

    I am no expert here, but I don't believe that is possible.

    > I do know when this floating window is supposed to be
    > on screen and when it's not

    <...>

    So why not use [NSApp activateIgnoringOtherApps: YES], do all the stuff you need to do and finally use [NSApp deactivate] to resign control?
  • On Thu, Mar 25, 2010 at 9:25 PM, Knut Lorenzen <knut...> wrote:

    >
    > So why not use [NSApp activateIgnoringOtherApps: YES], do all the stuff you
    > need to do and finally use [NSApp deactivate] to resign control?
    >
    > I don't need to activate the app to display a window with a level higher
    than NSNormalWindowLevel. This works fine even when the app is hidden. The
    only problem is the situation described above, when the app is frontmost and
    the user actively decides to hide it. Then all visible windows are ordered
    out (by NSApp, I presume, or perhaps the window manager? I haven't really
    looked into this yet).

    As for it not being possible, that's what I'm thinking too, as my googling
    has lead to nothing. But I figured it was worth asking anyhow, in case there
    is some snazzy method in NSApp I'm not aware of that I can override.

    -F
  • On Thu, Mar 25, 2010 at 9:55 PM, Philip Mobley <phil...> wrote:

    > On Mar 25, 2010, at 12:52 PM, fabian wrote:
    >
    >> Sorry for being unclear. I want NSApp to behave normally, i.e. when the
    > user hides it (with Command+H) the menu bar and all windows _except this one
    > window_ should hide. I do know when this floating window is supposed to be
    > on screen and when it's not; it's displayed for a few seconds in response to
    > a hotkey - but I don't want to have to delay the hiding of NSApp until the
    > window has been ordered out (if the user decides to hide it when the window
    > is on screen). I hope this clarifies my goal.
    >
    > I would make this a separate app with no menu and no dock icon (and
    > disabled from appearing on Force Quit list).  That way you just send a
    > message from your standard app to this visualNofication app to display its
    > content (whatever that may be).
    >
    >
    Yes, that is an option that has crossed my mind. Actually the app already
    has a background agent, so implementing it would be trivial. That's probably
    the route I'll choose if there's no other option.

    Thanks.

    -F
  • On Mar 25, 2010, at 12:52 PM, fabian wrote:

    > Sorry for being unclear. I want NSApp to behave normally, i.e. when
    > the user
    > hides it (with Command+H) the menu bar and all windows _except this
    > one
    > window_ should hide.

    Easy: just set window.canHide = NO;

    —Jens
  • On Fri, Mar 26, 2010 at 12:05 AM, Jens Alfke <jens...> wrote:

    >
    > On Mar 25, 2010, at 12:52 PM, fabian wrote:
    >
    > Sorry for being unclear. I want NSApp to behave normally, i.e. when the
    >> user
    >> hides it (with Command+H) the menu bar and all windows _except this one
    >> window_ should hide.
    >>
    >
    > Easy: just set window.canHide = NO;
    >
    > —Jens
    >
    >
    Ha! I can't believe I never saw that one *blushes*. Thanks!
  • On Mar 25, 2010, at 1:10 PM, fabian wrote:

    > Is it possible to prevent a window from hiding when NSApp is hidden, so it
    > always stays on screen? I only want the menu bar to go away.

    Honestly, it sounds like what you really want is to spin off this window into a separate process with LSUIElement enabled, with which the main app can communicate using some form of inter-process communication. That way, instead of just hiding, you can quit the “setup” application outright, and just have the daemon running in the background without taking up a space in the user’s Dock.

    Charles
previous month march 2010 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