nswindow

Why do I have to call showWindow on my NSWindowController twice on 10.5?

情到浓时终转凉″ 提交于 2019-12-06 07:28:27
问题 I've got a subclass of an NSWindowController that I'm using to load a window from a nib and show it on the screen. Below is the code that is called when I want to show the window. On 10.6 when showCustomWindow is called the window is displayed, but on 10.5 this method has to be called twice to get the window to display. -(IBAction)showCustomWindow:(id)sender { if(!windowController){ windowController = [[MyWindowController alloc] initWithWindowNibName:@"MyWindow"]; } [windowController

How to create a NSPanel modally popuped from NSWindow (Cocoa programming)

一笑奈何 提交于 2019-12-06 07:08:45
问题 like NSPanel displayed after a button clicked in the NSWindow. I looked for a lot but there is no simple example. Thanks for any help. 回答1: It can be done like this: -(IBAction)showButtonAction:(id)sender { [[NSApplication sharedApplication] beginSheet:panelOutlet modalForWindow:self.window modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:nil]; } Attention: Don't forget to uncheck NSPanel 's Visible At Launch checkbox in Attributes Inspector and

Dynamically resize NSWindow based on NSOutlineView height

喜欢而已 提交于 2019-12-06 06:40:56
I have read many answers to questions about dynamically resizing NSWindows and nothing has quite worked yet. I have built a 'popover' like window to be displayed form the menu bar, I couldn't use NSPopover because it isn't quite customisable enough in terms of design. My view hierarchy current looks like this: NSWindow Subclass - NSView (clears the titlebar rendering, draws popover arrow) - NSView (contentView) - NSOutlineView (main table of content) - NSView (window footer) What I need is for the window to expand and contract with items in the NSOutlineView expanding and contracting, so that

Cocoa app not loading views or running code on High Sierra

可紊 提交于 2019-12-06 06:31:51
问题 I have an app on the Mac AppStore and many users have recently written to say it doesn't work on High Sierra (possibly 10.13.6, its hard to extract specific information from them). I managed to reproduce the issue on a friend's device, however I won't be able to use the device to build with Xcode etc. The issue seems to be the NSViewController doesn't load it's subviews at all! The grey view controller shown below should have dropdowns and buttons in it. I also noticed that closing the grey

How to give focus to NSWindow loaded from NIB?

我怕爱的太早我们不能终老 提交于 2019-12-06 05:44:34
问题 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:

Rounded NSView in a Transparent Window

坚强是说给别人听的谎言 提交于 2019-12-06 05:35:21
问题 I'm trying to make a transparent NSWindow with a rounded view in there. I'm trying to have a rounded view with a transparent window. This is what it looks like now: (see the little dots in the corners) Here's another example with the border radius set to 10px (set in NSView drawRect): I am using code from this Apple sample: https://developer.apple.com/library/mac/#samplecode/RoundTransparentWindow/Introduction/Intro.html Specifically this method in my NSWindow subclass: - (id

Window-less Cocoa application

允我心安 提交于 2019-12-06 04:36:33
问题 I'm a complete beginner in Objective-C and Cocoa. I would like to create a window-less application, which just shows a NSStatusItem in the system tray. The tray works fine, however, there is one problem. For some reason my application automatically creates a window for me, which I do not want. I thought it was caused by the automatic Interface Builder template created when I created the application in Xcode, so I deleted the .nib file from the project. However the window still gets created.

How can I get a two-row toolbar like in Mail.app and Xcode?

送分小仙女□ 提交于 2019-12-06 04:28:06
问题 I'm trying to add a "second row" after my NSToolbar in my app, that remains part of the title bar. As an example, Mail has a thin gray divider line below the NSToolbar with some extras items below that. Very specifically, when the window is put into fullscreen mode, that second "row" stays attached to the title bar as it slides down under the system menu bar. Xcode has a similar story. I tried setting my NSWindow to textured and placing my second row controls directly in the content view of

Minimize / miniaturize cocoa NSWindow without titlebar

本秂侑毒 提交于 2019-12-06 02:46:46
I'm stuck! Obviously... because I'm posting a question here. I have built my own custom window controls for my OS X / cocoa app. The close button works great -- no problems. The minimize button doesn't work at all when I disable the titlebar. So when the title bar is on like the image above and I hit this method, the minimizing works fine: ViewController.h @interface ViewController : NSViewController { - (IBAction)minimize:(id)sender; @property (strong) IBOutlet NSButton *btn_minimize; } @end ViewController.m @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; } -

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

▼魔方 西西 提交于 2019-12-06 02:32:40
问题 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 can detect the window being closed using the -windowWillClose: delegate callback. But this callback is also called when I close the window programmatically after the dialog succeeds. I also know I could simply set up a BOOL flag, but is there a