How Do I Run Full-Screen Across Multiple Screens in OSX - macos

I am making a Cocoa application that presents a slide show of videos and images. If there are multiple screens connected (to a Mac Mini for example) I want different content to be shown on each screen. Each NSWindow should be full screen on each NSScreen.
When developing this on OSX 10.8 I set each NSWindow frame to a NSScreen frame with NSBorderlessWindowMask. I did not explicitly use NSApplicationPresentationFullScreen on NSApplication, I used NSApplicationPresentationHideDock and NSApplicationPresentationAutoHideMenuBar.
There seem to be some problems with this approach. Some OSX events seem to force the Menu Bar into view and permanently shift the windows down.
Is there a better approach to this now that OSX Mavericks has updated full screen support? Can I open an NSApplication in true fullscreen mode and force a separate NSWindow to each NSScreen?
Thank you.

You could instantiate one NSWindow per screen and switch them to fullscreen:
[self.windowA setFrame:[[[NSScreen screens] firstObject] visibleFrame] display:NO];
[self.windowB setFrame:[[[NSScreen screens] lastObject] visibleFrame] display:NO];
[self.windowA toggleFullScreen:nil];
[self.windowB toggleFullScreen:nil];

Related

Change color of selected NSTabView Tab for OS X App

I'm working on an OS X application with Xcode and swift, and I am trying to get the color of the clicked NSTabView to change from it's default blue color. I can't seem to find much information on this, and when I do it is really old. It seems like it is much easier to make changes with iOS, but I specifically need changes on my OS X App in Swift.
Can you not do it within Interface Builder?
I have done that by changing the colour of window where I am switching from one tab to other.
[windowMain setBackgroundColor:[NSColor grayColor]];
or any colour.

Mac Cocoa WebView (WebKit) - YouTube videos show as black squares but audio still works and able to right click

I am trying to access youtube.com through a WebKit WebView in my native Mac App.
The problem is that YouTube videos just show as black squares (see image below). However, if I click them they start to play (but stay black) - the sounds starts. I can also right click and the YouTube right click menu comes up (with things like 'Stats for Nerds').
Does anyone know what is happening here?
I use the standard WebView component, dragged in in Interface Builder. In my header I have the standard:
IBOutlet WebView *firstWebView;
and in my .m the standard:
[firstWebView setHidden:FALSE];
[[firstWebView mainFrame] loadRequest:[NSURLRequest requestWithURL: [NSURL URLWithString:#"http://youtube.com"]]];
The same thing happens when I access a site with an embedded YouTube video.
Thanks!
Sam
Found the answer - as of OS X Mavericks you'll need to call this for WebView's if you want Flash to render correctly:
[self.webView setLayerUsesCoreImageFilters:YES];
Docs: https://developer.apple.com/library/mac/releasenotes/AppKit/RN-AppKit/#//apple_ref/doc/uid/TP30000741-CH2-SW49

Application go fullscreen at startup

Since MacOSX Lion, Cocoa supports a new fullscreen feature.
I implement it in my application window thanks to the following instruction from my application delegate:
[_window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
Is it possible to go to this presentation at startup?
Thanks for help!
Edit: I still want the fullscreen menu bar feature (which doesn't work with enterFullscreenMode:withOptions:
You can make window's view full screen like this:
[self enterFullScreenMode:[NSScreen mainScreen] withOptions:nil];

Designing views/windows in Mac OSX first time

I am about to tackle my first Mac OSX project after developing for iOS.
In my iOS applications, it is clear to me the whole NavigationViewController->MyViewController->MyViews paradigm.
A bit more background on the iOS app so it would be easier to understand me:
The application is some sort of graphic viewer. Once you login you have a list of drawings, and if you select one, it opens it up.
Now in the iOS app I have a custom UIViewController that have some menu UI and a UIScrollView that holds a UIView in which I draw the drawing.
The custom UIViewController is responsible for acting as the "application" where the UIView inside is merely a graphic context.
Now - back to Mac:
I was thinking that my main window would show the drawings and once one is selected,
I would add another window with an NSView that is the graphic context of the drawing,
and the window will be acting as the UIViewController in the iOS app.
Does that make sense?
You can have NSViewController or NSWindowController on the Mac, to put your controller logic in. If you're going for separate windows, subclassing NSWindowController would make sense.

Using Webkit to create Skinable custom windows on OSX

There are tutorials for using a webkit view inside a cocoa application to achieve skinnable contents, but what would I do if I wanted to use webkit to create custom, skinnable windows?
Examples would be dashboard widgets, or
BowTie
Beware, I'm a noob.
I've never tried it, but I think you'd just set a WebView as the content view of a transparent borderless window, and tell the WebView not to draw a background. That way, the content of the WebView would define the window boundary.
You create a borderless window by passing NSBorderlessWindowMask to the -initWithContentRect:styleMask:backing:defer: method of NSWindow, and you can set its background to transparent by calling [window setBackgroundColor:[NSColor clearColor]].
You'd have to handle dragging of the window etc yourself. It will probably get a bit messy.
To be honest, it's not something I'd attempt as a first Cocoa project.

Resources