Showing a modal NSWindow, without activating the other application windows

后端 未结 4 1038
误落风尘
误落风尘 2020-12-15 12:53

I have an NSStatusItem that is properly displaying in the MenuBar. One of the items (when clicked) displays a modal NSWindow from my application, which is meant

4条回答
  •  醉梦人生
    2020-12-15 13:32

    You can try something like:

    ...
    if ([NSApp isHidden])
        [myWindow makeKeyAndOrderFront:self];
    else
        [NSApp runModalForWindow:myWindow];
    ... 
    

    and when finish:

    ...
    if ([NSApp isHidden])
        [myWindow orderOut:self];
    else
        [NSApp stopModal];
    ... 
    

提交回复
热议问题