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];
Related
I am a newer one for MACOS development. I have created an instance of NSWindowController.
Is it possible to show (un-minimize) the window when the NSWindow is minimized by user ?
Thanks
You can do this with
window.makeKeyAndOrderFront(self)
UPDATE:
There is a function especially to deminiaturize a window but the effect is the same.
window.deminiaturize(self)
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];
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.
I want to develop a plugin with Safari. Now I wan to make a demo for add a button into it's MainWindow or menu into it's MenuBar. I have seen to Document WebKitPluginProgTopic and the sample:/Developer/Examples/Webkit/WebKitMoviePlugIn . But they didn't tell the full process of make a plugin with safari and how to add some menu or button in the safari window . Someone can give me some advice or simple code to resolve this problem, Thank you very much!
The plug-in architecture isn't thought for enhancing the browser but to support special media formats like flash or quicktime. The problem is that the plugin is only loaded when the corresponding media type is found.
Agile Web Solutions have found a way to load the plug-in all sites in 1Password and insert code into Safari. They've documented it in their blog. For other means of injecting code have a look at this question: InputManager plug-ins in Snow Leopard.
I haven't got any experience in building menus programmatically, but it should work like this:
NSMenu *newMenu = [[[NSMenu alloc] initWithTitle:#"MyMenu"] autorelease];
NSMenu *mainMenu = [NSApp mainMenu];
[mainMenu addItem:newMenu];
Changing the windows isn't that easy. Your best guess is probably [NSApp orderedWindows], which exists only for scripting purposes, but should be usefull to your task.
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.