Questions tagged [nswindowcontroller]

A NSWindowController object manages a window, usually a window stored in a xib file.

The management of a NSWindowController entails:

  • Loading and displaying the window
  • Closing the window when appropriate
  • Customizing the window’s title
  • Storing the window’s frame (size and location) in the defaults database
  • Cascading the window in relation to other document windows of the application

A window controller can manage a window by itself or as a role player in the Application Kit’s document-based architecture, which also includes NSDocument and NSDocumentController objects. In this architecture, a window controller is created and managed by a “document” (an instance of an NSDocument subclass) and, in turn, keeps a reference to the document.

372 questions
42
votes
2 answers

NSWindowController clarification of understanding

I have used NSWindowController in projects several times, and feel like I have a (very)rough grasp of the concepts behind this important class. What I would like to do with this post is to clarify/correct my own understandings, and hopefully help…
Loz
  • 2,198
  • 2
  • 21
  • 22
33
votes
1 answer

NSWindowController/NSViewController "Presentation" setting in Storyboard

What exactly does the Presentation option(in Attribute Inspector) do in StoryBoard for Cocoa. It gives two options to select from Single Multiple P.S When googled the title, results are related to powerpoint presentation
Kaunteya
  • 3,107
  • 1
  • 35
  • 66
33
votes
5 answers

Subclassing NSWindowController in Swift and init(windowNibName)

I am trying to start a new document based Cocoa project in Swift and want to create a subclass of NSWindowController (as recommended in Apple's guides on document based apps). In ObjC you would make an instance of an NSWindowController subclass…
Martin
  • 333
  • 1
  • 3
  • 6
33
votes
3 answers

Difference between NSWindowController Vs NSViewController

I am coming from iOS background and starting to learn Cocoa. On iOS unless we have multiple targets for iPad and iPhone we usually have one Window and manage the screen using UIViewControllers. Where every new screen will most of the time will map…
26
votes
2 answers

Why isn't my sheet attached to the window it's run for?

I have a NIB which contains two windows, one is the app's main window visible at launch and the other is a custom sheet (and therefore not visible at launch). When the sheet is required my controller calls: [NSApp beginSheet: sheetWindow…
user23743
22
votes
2 answers

Event for Red Close button of NSWindowController

How can I handle an event where I click on the red close button of a NSWindowController? Reason for asking is that I have a video playing in a new NSWindowController window and when user clicks on the red close button, the audio continues playing,…
Jason
  • 1,059
  • 1
  • 13
  • 32
19
votes
1 answer

How to get notified when NSWindow closes

how can I take notice when an NSWindow should or will get closed? I'd like to have something like the windowWillClose. Unfortunately NSWindowController does not have as much convenient methods as UIViewController has, for example. So what's the best…
flohei
  • 5,248
  • 10
  • 36
  • 61
16
votes
4 answers

Handle close event of the window in Swift

How to handle close event of the window using swift, for example, to ask "Are you sure you want to close the form?" The form will be closed in the case "yes" and not closed in the case "no". Showing message box is not a problem for…
Evgeniy
  • 403
  • 1
  • 8
  • 18
13
votes
2 answers

How do I open an NSWindow and have the window selected and in focus?

I am trying to open a NSWindow using the following code: NSWindowController *window = [[NSWindowController alloc] initWithWindowNibName:@"MainWindow"]; [window showWindow:nil]; The window opens okay but the previous window is still the mainWindow…
Luke
  • 6,195
  • 11
  • 57
  • 85
11
votes
2 answers

Is it possible to bring window to front without taking focus?

I am working on an application for my personal usage that will remind me of stuff at regular intervals and/or will require text entry. Hence this popup window has an NSTextField. If the window pop's up when I am in the middle of typing, my typing…
Jay
  • 19,649
  • 38
  • 121
  • 184
11
votes
2 answers

NSWindowController without a nib file in Swift

I am a beginner Cocoa developer. The team I have been hired by does OS X development in Swift without using nib files (except apparently for the main menu). So, I am trying to learn this before I join the team. Here is what I have so far: I created…
RookiePro
  • 633
  • 1
  • 9
  • 18
11
votes
2 answers

Show Window without activating (keep application below it active)

I need to show a window (without title bar) above third party applications without my window taking focus. I have tried using an NSPanel and setting enabling non-activating, but that didn't help. I tried orderFront:self, but that didn't help…
user429620
10
votes
2 answers

Can't use storyboard custom instantiated window controller

I am getting what feels like a bug when trying to custom instantiate a window controller from a storyboard. I am using NSStoryboard.instantiateController(identifier:creator:), which is a new function as of MacOS 10.15. The block of code in question…
10
votes
4 answers

NSWindowController windowDidLoad not called

I have a simple Cocoa app using a NSWindowController subclass. In the nib I have set: File Owner's class to my NSWindowController subclass The 'Window' outlet of the File's Owner to the main NSWindow in the nib. The init method of my…
Mike Hornblade
  • 1,544
  • 2
  • 14
  • 19
10
votes
1 answer

NSWindowController showWindow:nil does nothing

Like in the title, [myWindowController showWindow:nil] doesn't work. Here are some facts you may need to know: My window controller: KRAuthenticationWindowController Interface builder file: AuthenticationWindow.xib File's Owner is…
akashivskyy
  • 44,342
  • 16
  • 106
  • 116
1
2 3
24 25