nswindowcontroller

Cocoa Storyboard Responder Chain

若如初见. 提交于 2019-12-05 03:50:30
Storyboards for Cocoa apps seems like a great solution as I prefer the methodology you find in iOS. However, while breaking things up into separate view controllers makes a lot of logical sense, I'm not clear as to how to pass window control (toolbar buttons) or menu interaction down to the view controllers that care. My app delegate is the first responder and it receives the the menu or toolbar actions, however, how can I access the view controller that I need to get that message to? Can you just drill down into the view controllers hierarchy. If so, how do you get there from the app delegate

NSWindow launching with wrong size after setting contentViewController to NSTabViewController

浪子不回头ぞ 提交于 2019-12-05 02:00:15
问题 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 NSTabViewController subclass. Now, when I run the application, the NSWindow opens with a size of 500x500 instead of the size of the first tab. What's more, there is no view I can see in the storyboard that has a size of 500x500, and that size isn't being

How do I open an NSSheet in Mavericks?

我只是一个虾纸丫 提交于 2019-12-04 12:55:09
In Mavericks, the methods to open and close NSSheets has changed. And to make it tougher, the Release Notes do not match the current documentation (see below). I'm trying to do this: MainSheetController (NSWindowController): -(IBAction)callSheet:(id)sender { [sheetController openSheet]; } SheetController (NSObject): (void)openSheet { [[NSBundle mainBundle] loadNibNamed:sheetName owner:self topLevelObjects:nil]; NSLog(@"1"); [self.mainWindowController.window beginSheet:self.sheet completionHandler:nil]; NSLog(@"2"); } I get to 2, with no errors or warnings, but no sheet.. Current Documentation:

How show sheet loaded from xib? (MacOSx)

帅比萌擦擦* 提交于 2019-12-04 09:56:13
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 IBOutlet to the NSPanel. What I am looking for is something like: ... MyController *controller = [[MyController alloc] init]; [NSApp beginSheet:controller.panel modalForWindow:[NSApp mainWindow] modalDelegate:controller didEndSelector:nil contextInfo:nil]; ... Question: Must MyController inherit from NSWindowController or NSObject ?. I tried

How to give focus to NSWindow loaded from NIB?

二次信任 提交于 2019-12-04 09:37:20
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 window (with keyboard focus) is moved slightly, before creating the new window (via cmd+n). This is the result: The bottom, focused window is the original window. The unfocused window on top is the newly created window. This is the relevant code: AppDelegate.h: - (IBAction)newDocument:(id) sender; AppDelegate.m: - (IBAction)newDocument:(id) sender {

New NSWindow from application - mission impossible?

对着背影说爱祢 提交于 2019-12-04 05:40:33
问题 OK, what am I doing wrong? 1. Created cocoa app and appDelegate named: window2AppDelegate 2. window2AppDelegate.h #import "PrefWindowController.h" @interface window2AppDelegate : NSObject <NSApplicationDelegate> { NSWindow *window; PrefWindowController * ctrl; } @property (assign) IBOutlet NSWindow *window; - (IBAction) buttonClick:(id)sender; - (IBAction) buttonCloseClick:(id)sender; @end 3. in xib editor, window connected to window controller - set to appdelegate, buttonclick actions to

NSWindowController/NSViewController “Presentation” setting in Storyboard

笑着哭i 提交于 2019-12-03 22:05:53
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 The presentation style affects "Show" segues. Possibly it affects other segues too, but I only tested a Show segue. I tested on OS X 10.10.5 (Yosemite) with Xcode 7.1.1. If a window controller's presentation style is "Multiple" (the default), then a Show segue to the window controller always loads a new instance of the window controller from the storyboard. This means that you

NSWindow launching with wrong size after setting contentViewController to NSTabViewController

爱⌒轻易说出口 提交于 2019-12-03 16:20:12
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 NSTabViewController subclass. Now, when I run the application, the NSWindow opens with a size of 500x500 instead of the size of the first tab. What's more, there is no view I can see in the storyboard that has a size of 500x500, and that size isn't being programmatically, either. The window itself is set to a different size, as is the view in the

Difference between NSWindowController Vs NSViewController

佐手、 提交于 2019-12-03 09:11:28
问题 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 to a UIViewController . However on cocoa this seems to be the otherway around where a new screen/window is manage by NSWindow and it's subcomponents are managed by NSViewController . So if I have multiple window app I should have separate

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

时光毁灭记忆、已成空白 提交于 2019-12-03 01:17:41
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 modalForWindow: mainWindow modalDelegate: self didEndSelector: @selector(didEndSheet:returnCode:contextInfo:) contextInfo: nil]; which displays the sheet window and starts a modal session, but the window has a standard Aqua title bar, is not 'connected' to the main window and can be moved around just like a regular window. Needless to say, this is not