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
4
votes
1 answer

On NSWindowController, setting contentViewController updates the window's position, how can I stop this?

I have a NSWindowController with an NSWindow, I am having an issue where, if I set the controller's contentViewController, the frame of the NSWindow updates beyond my expectations Window is at a origin, say (500,500), and size is (100,100) I drag…
A O
  • 5,516
  • 3
  • 33
  • 68
4
votes
0 answers

Disable NSWindow snapping / stickiness programmatically

In recent versions of macOS, NSWindow's default behavior is to become sticky when being resized/re positioned near to another window (even in a different application). Does anyone know of a way to disable this for a specific window in my app? Or at…
Max Chuquimia
  • 7,494
  • 2
  • 40
  • 59
4
votes
1 answer

macOS application like Photos.app on macOS

I'm trying to create a macOS app like Photos.app. The NSWindowController has a toolbar with a segmented control. When you tap on the segmented control, it changes out the the NSViewController within the NSWindowController. What I have so far is an…
Mario A Guzman
  • 3,483
  • 4
  • 27
  • 36
4
votes
1 answer

How show sheet loaded from xib? (MacOSx)

I have a xib file with only an NSPanel in it, I'm trying to show this panel as modal sheet (with beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:). The file's owner for this xib is a controller class "MyController" which has the…
Bruno Berisso
  • 1,091
  • 11
  • 33
4
votes
2 answers

Can't drag or move custom NSWindow

I create a NSWindowController and NSViewController using Interface Builder, And then, i removed the NSWindow's titlebar so that I can custom Window. i create a class subclass NSWindow And do following things in class. override var canBecomeKey: Bool…
J.Wu
  • 41
  • 5
4
votes
1 answer

Cocoa show NSWindow on a specific screen

In a Mac app how can I open a NSWindow on a specific NSScreen (let's say the second screen)? This is how I show the window, but it only shows on the main screen self.windowController = NSStoryboard(name: "Main", bundle:…
hklel
  • 1,624
  • 23
  • 45
4
votes
1 answer

When should I extend NSDocument and when should I extend NSWindowController?

I've an application that holds a main window with a list of items, and from that window an undetermined number of windows can be opened. Each of those windows can hold several instances of a model object, with those instances listed in a drawer. I…
ruipacheco
  • 15,025
  • 19
  • 82
  • 138
4
votes
1 answer

Zoom window for new documents to full screen

This should be straightforward but I couldn't find anything on either SO or Google on this topic so.. What's the best way of zooming new document windows to full screen (i.e. not the full screen mode but just maximizing the window) for NSDocument…
ATV
  • 4,116
  • 3
  • 23
  • 42
4
votes
1 answer

Cocoa NSWindowController And NSWindow Not Deallocing

I'm working with an NSWindowController to implement a preferences window. Apple's documentation states that by default the controller and window aren't deallocated, because it's useful to not have to reload everything, which makes sense. But their…
gngrwzrd
  • 5,902
  • 4
  • 43
  • 56
4
votes
2 answers

Initial NSWindow size as percentage of screen size

I would like to set my NSWindow size as a function of the screen size. There is an option in Interface Builder to set it in points, but not as a function of the screen size. How can I set it programmatically as a default? Note that I still want UI…
4
votes
2 answers

Keeping and NSDocument open without any windows

I have a document-based application which has two document types. The first NSDocument subclass is the "main" document (mainDoc) and it's .xib file is the main editing window for the application. The second NSDocument class is a data source file…
Tangler
  • 168
  • 9
4
votes
1 answer

Best way to toggle "Show/Hide" menu item in Cocoa Desktop

My app has an 'inspector' panel defined by a .xib file and a custom window controller class: AdjustmentsWindow.xib and AdjustmentsWindowController.m. I want to have a Window -> Show Adjustments menu item in the application's main menu bar, that when…
Nicolas Miari
  • 16,006
  • 8
  • 81
  • 189
4
votes
3 answers

NSWindowController can't capture ESC without WebView is added to the window

I create a subclass of NSWindowController from File->New, and with the "With XIB for user interface" option checked. So I create 3 new files. Then I use Interface Builder to add exactly ONE view into the window. And have this code in…
ideawu
  • 2,287
  • 1
  • 23
  • 28
4
votes
2 answers

Owner other than window controller in [NSWindowController initWithWindowNibName:owner]?

What I would like to know is how does the window controller I initialize with NSWindowController *c=[[NSWindowController alloc] initWithWindowNibName:@"Win" owner:myObj] know which window it should control in the Win.xib file if myObj is not the…
Nickkk
  • 2,261
  • 1
  • 25
  • 34
4
votes
3 answers

How to stop modal with close button in NSWindowController?

I want to stop modal when the user clicks the red close button in NSWindowController. In the NSWindowController, there are "OK" and "Cancel" buttons. - (IBAction)okButtonClicked:(id)sender { [NSApp stopModalWithCode:NSOKButton]; [self.window…
Yun
  • 5,233
  • 4
  • 21
  • 38