How to un-mininize NSWindow programmatically ? - macos

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)

Related

Make a window on screen using window id

I am new to Mac API. I can get the list of window from the following function.
NSArray *windowInfos = (__bridge_transfer NSArray*)CGWindowListCopyWindowInfo(kCGWindowListOptionAll, kCGNullWindowID);
Is it possible to make a window on screen if the window is not on screen. If so, How can I do that?
Thanks in advance
Does the window you are trying to make visible belong to your application? If so, you more likely to just want to do something like [myWindow makeKeyAndOrderFront:nil], where myWindow is an NSWindow* outlet connected to a window in a nib file in your app. Or does the window you are trying to make visible belong to a different application? If so, it would seem rather strange to be trying to control the visibility of windows in a different app; perhaps in that case you could be more specific about what exactly you are trying to achieve, and perhaps there would be a better mechanism (distributed notifications, for example) to achieve it.

NSWindow vs ViewController - OS X - Cocoa

I have been making iOS apps for a while now and I decided that I wanted to start working on making some of them for the Mac too.
The question I have is this: is there any need for an NSWindow, now that developing for the Mac is so similar to iOS??
So I made a simple cocoa application using Xcode and its comes with a storyboard called "Main", just like on iOS.
In that storyboard file, there is a NSWindow which then links to a NSViewController.
Can I get rid of that NSWindow? As I tried setting the NSViewController as the "Initial Controller" and the app still works fine. So whats the point of the NSWindow?
Also, what class links to the NSWindow? I was trying to blur that background of the NSWindow, but I have no way of linking code to the NSWindow.
Sorry for my stupid questions, but I am completely new to development for OS X.
Thanks for your time, Dan.
Those are many questions in one question:
Can I get rid of NSwindow? No, you need a window to show you views.
What is the point of the NSWindow? NSWindow is needed as the window in which the views are displayed and your events are going up the responder chain.
What class is linked to NSWindow? Obviously the NSWindow class, but that is not what you want to know. I think you want to know the delegate that controls NSWindow. This is NSWindowController, although for the MainMenu.xib it is NSAppDelegate.
Hope this gives you the answers you need. An example for working with views in a window is given in this question.
Please, see for further details the windows programming guide, which states:
The NSWindow class defines objects that manage and coordinate the
windows an application displays on the screen. A single NSWindow
object corresponds to at most one onscreen window. The two principal
functions of an NSWindow object are to provide an area in which NSView
objects can be placed and to accept and distribute, to the appropriate
views, events the user instigates through actions with the mouse and
keyboard.
For the question: Can I get rid of NSwindow? I have further comments. In most cases, You need a NSWindow to show view on screen; but in special case you don't, for example, a popup view when you click a NSStatusItem.
So my answer is whenever you need to respond window event such as min/max, you need NSWindow as the view container.

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];

Implementing a Preferences NSWindow

As we all know, there is some sort of "trend" it seems between Mac apps. They all have the same panel on the top of their preferences window:
I say "trend", because I searched the Mac OS X HIG Without any luck ...
So, how can I achieve this look?
(It's easy to use the textured Window .. but, the buttons and how they look when clicked. That's what I want to know)
Edit:
Thanks #valexa.
It seems I can only use NSToolbar under a window's titleBar.
I would like to add it inside a custom NSView ?
At least something that looks similar?
That would be the NSToolbar https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSToolbar_Class/Reference/Reference.html

UISlider in Cocoa

In a Cocoa app I added a UISlider. If I run the program without adding any code then I can drag the slider left and right. However, if I assign an IBOutlet to it, once I touch the slider, the application exits. Why is that?
Alright, I solved the problem. If I make the application a Window-based application, then I don't have any problems. If I make the application a View-based application, then the problem occurs. Why is that?

Resources