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

NSWindow set frame higher than screen

I need help. I have an app like Adium with vertical sliders. But my app change the window height, depending on content. In case if the Screen height less than my app'a window height my window reduces the height automatically. When I'm trying to use…
BUDDAx2
  • 399
  • 1
  • 4
  • 20
5
votes
1 answer

Open new NSWindowController

I am new to Cocoa programming. I have a main NSWindowController and would like to open a second sub NSWindowController. can't seem to find the code anyway. Can anyone help?
Jason
  • 1,059
  • 1
  • 13
  • 32
5
votes
2 answers

How to give focus to NSWindow loaded from NIB?

I'm using NSWindowController to load a window from a NIB. However, when I call showWindow:, the window is visually topmost, but the focus remains where it was (instead of moving it to the new window). It's easy to see this happening when the first…
Zr40
  • 1,910
  • 18
  • 20
5
votes
1 answer

close event NSWindow

I have an application, where a second NSWindow is opened by pressing a button. This new window is opened using [NSApp runModalForWindow:]. I want to be able to determine if the user closes the second window, in order to stop the modal.
Radu Paise
  • 285
  • 1
  • 6
  • 16
5
votes
3 answers

NSWindow launching with wrong size after setting contentViewController to NSTabViewController

I have an Xcode project with an NSWindowController whose contentViewController was set to a subclass of NSViewController. I recently removed the NSViewController subclass from the storyboard and replaced the contentViewController with an…
5
votes
3 answers

How to close window (NSWindowController) by hitting the ESC key?

Issue I would like the user being able to close a window by hitting the ESC key but I can't get it to work in this specific case, hitting ESC triggers an error sound (the "no you can't do that" macOS bloop) and nothing happens. Context I'm making a…
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
5
votes
1 answer

Error when using NSWindowController

I just started a new Cocoa project after a long time... And I don't know why, but I always get an error when calling a xib by a NSWindowController. What I do is really very simple: I have a new project as a starting point and then I don't wantz to…
usermho
  • 207
  • 4
  • 11
5
votes
2 answers

NSWindowController in Swift. Subclassing and initializing with Nib

In a test Swift project, I am subclassing NSWindowController. My NSWindowController subclass is designed to work with a particular Nib file. It is desirable, then, that when my window controller is initialized, the nib file is automatically loaded…
George
  • 1,235
  • 10
  • 23
5
votes
1 answer

Setting NSWindow position in current screen

I am newbie in objective-c.I have created a main window which I want to display in the right bottom of the current screen. I tried the following code - (void)windowDidLoad { NSPoint pos; pos.x = [[NSScreen mainScreen]…
boopathy
  • 427
  • 2
  • 9
  • 20
5
votes
1 answer

How to draw on a transparent NSWindow with a transparent NSView?

I want to draw on the screen with a transparent background, so that everything (e.g. open applications are still visible). In windowDidLoad of my custom NSWindowController i have the follwing: [self.window setOpaque: NO]; [self.window…
mc_plectrum
  • 363
  • 4
  • 12
5
votes
1 answer

How to use NSWindowController to show a window in standard application?

I created a new blank standard application using Xcode template. Removed the window in MainMenu.xib and I created a new customized NSWindowController subclass with a xib. They were named "WYSunFlowerWindowController.h" and…
morphinewan
  • 434
  • 2
  • 6
  • 17
5
votes
2 answers

Prevent save prompt when closing NSWindow

I have a document-based Cocoa app that uses a secondary NSWindow for a preview mode (with shouldCloseDocument set to NO). If the document is dirty (edited without saving) and I close the secondary NSWindow, a "Do you want to save the changes made to…
hpique
  • 119,096
  • 131
  • 338
  • 476
5
votes
1 answer

How to detect that my window is being closed using the red window button?

I have a dialog window that can be cancelled through a custom Cancel button or using the system red window button. I need to perform some simple logic when the dialog is cancelled. How do I detect that the user has pressed the red button? I know I…
zoul
  • 102,279
  • 44
  • 260
  • 354
4
votes
0 answers

How to prevent multiple instances of the same window from opening in macOS?

I am making a Mac Menu Bar app and it has a Preferences option. When the user clicks on it, a Preferences window opens up that shows all the settings for the app. I open the Preferences window like: let storyboard = NSStoryboard(name: "Main",…
Ram Patra
  • 16,266
  • 13
  • 66
  • 81
4
votes
1 answer

Cascading in custom NSWindowController

I have a document-based application. I override NSDocument's makeWindowControllers to instantiate a custom window controller. Its initializer calls init(window: NSWindow?) of its superclass, i.e. it does not use any of the initializers that involve…
mistercake
  • 692
  • 5
  • 14
1 2
3
24 25