nswindow

Set NSWindow Size programmatically

筅森魡賤 提交于 2019-12-04 08:00:02
问题 How can I set the window size programmatically? I have a window in IB and I want to set the size of it in my code to make it larger. 回答1: Use -setFrame:display:animate: for maximum control: NSRect frame = [window frame]; frame.size = theSizeYouWant; [window setFrame: frame display: YES animate: whetherYouWantAnimation]; Note that window coordinates are flipped from what you might be used to. The origin point of a rectangle is at its bottom left in Quartz/Cocoa on OS X. To ensure the origin

Creating a custom title bar on a standard NSWindow

风格不统一 提交于 2019-12-04 07:55:48
问题 I've been trying to build a specific look for my menubar app. I've been using a NSWindow with a NSBorderlessWindowMask style mask and setting [window setOpaque:NO] and [window setBackgroundColor:[NSColor clearColor]] . That gives me a blank canvas which works great for the title bar. Now I'm having problems with the view-based NSTableView I'm using for the listing. How can I clip the NSTableCellView s to the window's rounded corners? I started out just having a custom view wrapping the

Programmatically closing an NSWindow when it loses focus

末鹿安然 提交于 2019-12-04 06:34:31
I am making an image picker that will display an n by n grid of selectable button when the picker is popped up. This grid of buttons will be contained within an NSWindow but I would like for the window to be close automatically if the user clicks off the screen. Is there a flag that can be set so that when the window looses focus it will be closed automatically? There are two notifications that you may be interested in: NSWindowDidResignKeyNotification and NSWindowDidResignMainNotification . You can simply register for the one you're interested in in awakeFromNib (or windowDidLoad if you have

Why is my Cocoa NSWindow taking such a long time to become active?

℡╲_俬逩灬. 提交于 2019-12-04 06:10:36
问题 My app starts and the window shows (all controls are physically there) in an inactive-like state (controls grayed out and inactive to keys/mouse). It takes three to five seconds for the window to become active? Same pattern occurs when I switch back to this app from another. EDIT I have added logging in various Window, Delegate & Controller methods to determine where precisely the slowdown is occurring and all of these run before the slowdown: 1. 2015-02-08 15:22:16.032 Grid[40199:5354843]

How to show a NSPanel as a sheet

老子叫甜甜 提交于 2019-12-04 04:16:08
I'm trying to show a NSPanel as a sheet. I'm naively doing something along those lines: SheetController *sheetController = [[[SheetController alloc] initWithWindowNibName:@"Sheet"] autorelease]; [[NSApplication sharedApplication] beginSheet:sheetController.window modalForWindow:self.window modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:nil]; For some reason that eludes me, this isn't working. When this part of the code is called, the sheet momentarily flashes (because of the autorelease message). The sheet is never hooked to window. If anyone can

Cocoa: I've got my user's input - Now what?

和自甴很熟 提交于 2019-12-04 02:35:27
问题 In a nutshell what my program does is: it executes and takes user input periodically using nswindow (which is controlled by my NSWindowController object) and continues execution. here is my myController.mm which is calling and showing the window to take user input: EncryptPasswordDlgController encPassController = [[EncryptPasswordDlgController alloc] init]; [encPassController showWindow:self]; NSString *inputPassword = [encPassController password]; here is my nswindowcontroller object code:

How can I implement gesture recognizers in OS X?

淺唱寂寞╮ 提交于 2019-12-04 02:27:34
I have done quite a bit with gesture recognizers for iOS, but I am now doing work in OS X, and I am lost. I want to duplicate the functionality that exists like in Finder where you can two-finger swipe (on your magic mouse) to go back/forward through a directory tree. I have an NSWindow based app that looks very similar to Finder. I have used apps before that allows you to build your own gesture recognizers so I know it is possible to do it, but I don't see any documentation on it. What do I need to do to implement these gestures? You can read about Handling Trackpad Events in the Cocoa Event

How do I disable the Show Tab Bar menu option in Sierra apps?

吃可爱长大的小学妹 提交于 2019-12-03 23:47:58
I've got an app that uses a Toolbar in a NSWindow. I don't want users to be able to customize this toolbar for aesthetic reasons. In Sierra there's a new Menu option that gets inserted into "Menu > View" called Show Tab Bar . How do I disable this? Enabling it only seems to increase the tool bar's height as I don't have extra labels showing under the icons. You can also do this on IB, on the Window’s attributes inspector On 10.12, you need to now set the following when the window is created as Tab Bar is now available by default: [NSWindow setAllowsAutomaticWindowTabbing: NO]; If you don't

Disable window stretching Cocoa?

流过昼夜 提交于 2019-12-03 20:48:38
问题 How do I disable the stretching of the window at the bottom right? I would have to deal with auto-sizing and all that stuff, which would be unnecessary if I simply didn't allow the user to stretch the window size. 回答1: First you should set the maximum width/height equal to the minimum width/height in IB: Then you can disable the resize control by unchecking "Resize" in IB: 回答2: Select the window in Interface Builder and uncheck the "Resize" checkbox in the Attributes Inspector panel 来源: https

NSPopover to start in a detached state

孤人 提交于 2019-12-03 16:54:54
Is there a way to force the NSPopover to start in the detached state? I only see isDetached which is a read-only property for the state of the popover and an NSPopoverDelegate method detachableWindow(forPopover:) which lets me override the window that gets created. I'd like to essentially click a button and have the NSPopover start in the state in this photo. The style of this window is exactly what a product requirement is and I can't seem to find any NSWindow style settings that would make a window do something like this (nor an NSPanel) This detached popover functionality seems special in