How to assign application to all desktops (spaces) of Mac OS X Lion using Objective C?

前端 未结 1 1301
忘掉有多难
忘掉有多难 2021-02-05 11:50

I am trying to create an Application on Mac OS X Lion which requires application to be assigned to All Desktops (Spaces). This can be manually done by Right clicking on applicat

1条回答
  •  后悔当初
    2021-02-05 12:33

    You can use method setCollectionBehavior: of NSWindow with the NSWindowCollectionBehaviorCanJoinAllSpaces bitwise flag.

    It will make the window visible on all spaces.

    NSUInteger collectionBehavior;
    
    // Gets the current collection behavior of the window
    collectionBehavior = [ myWindow collectionBehavior ];
    
    // Adds the option to make the window visible on all spaces
    collectionBehavior |= NSWindowCollectionBehaviorCanJoinAllSpaces;
    
    // Sets the new collection behaviour
    [ myWindow setCollectionBehavior: collectionBehavior ];
    

    Note

    This method was introduced in Mac OS X 10.6.

    On Mac OS X 10.5, you'll need to use the canBeVisibleOnAllSpaces: method of NSWindow.

    0 讨论(0)
提交回复
热议问题