nswindow

NSOpenGLView, NSWindow & NSResponder - makeFirstResponder not working

℡╲_俬逩灬. 提交于 2019-12-23 13:00:17
问题 In the code below I am Initialising a NSViewController [a NSResponder], with a NSWindow , a NSOpenGLView , presenting the view and attempting to set the NSViewController as the windows first responder. It is not working. I was expecting to be able to hit a breakpoint in the keyUp: and keyDown: methods also below, but nothing is happening. Am I missing something? -(void)initwithFrame:(CGRect)frame { window = [[MyNSWindow alloc] initWithContentRect:frame styleMask:NSClosableWindowMask |

How to NOT highlight the NSButton's template image when clicked?

跟風遠走 提交于 2019-12-23 07:48:42
问题 I have NSButtons in each row of a NSTableView. The buttons images are set in IB and are black icons with alpha channel: The windows are set to dark mode with: window?.appearance = NSAppearance(named: NSAppearanceNameVibrantDark) And to normal mode with: window?.appearance = nil The goal is that the buttons should be black when the window is white, and should be white when the window is dark, without changing when clicked. In dark mode, in order to achieve the color change, I set the button's

deminiaturize NSWindow without making it key

感情迁移 提交于 2019-12-23 04:58:16
问题 I have main window and several child windows, i would like to show main window when user click on dock icon, but without making it a key window, if there just was one (it will become automatically key if there is no key window). Here is current code: if ( fMainWinDelegate ) { if (not [NSApp keyWindow]) { NSLog(@"AppDelegate::applicationShouldHandleReopen [fMainWinDelegate showWindow]"); [fMainWinDelegate showWindow]; } else { if ([fMainWinDelegate.window isMiniaturized]) { NSLog(@"AppDelegate

Why is [[NSWindow animator] setFrame…] very laggy sometimes?

我是研究僧i 提交于 2019-12-22 10:53:49
问题 So, I have the following code to show my NSWindow : [_window makeKeyAndOrderFront:self]; [NSAnimationContext beginGrouping]; [[_window animator] setAlphaValue:1.0]; [[_window animator] setFrame:NSMakeRect([[NSApp currentEvent] window].frame.origin.x - 102, [[NSApp currentEvent] window].frame.origin.y - 238, _window.frame.size.width, _window.frame.size.height) display:YES]; [NSAnimationContext endGrouping]; This code is called right after the user has clicked on the app's status bar icon, that

When exactly does an NSWindow get rounded corners?

雨燕双飞 提交于 2019-12-22 06:40:03
问题 (I found several similar questions, but nothing quite the same. Some were older than the OS in question. Some were doing crazy things, like completely custom windows. Nobody I found has instructions for how to make a perfectly ordinary window work correctly.) Starting in OS X Lion, standard windows have had rounded corners. Unfortunately, I'm having trouble replicating this in my application. When an NSView is pushed against the corner of an NSWindow, sometimes it stays clipped to the round

How to force an NSWindow to be always active/focused?

不打扰是莪最后的温柔 提交于 2019-12-22 06:02:10
问题 I have a transparent NSWindow that follows the user's screen everywhere he goes (the NSWindow stays in front of every app, no matter what, even fullscreen apps). In that NSWindow i have a mouseDown event that shows a popup. Let's say i'm on safari in fullscreen mode and i have my Window in front of it, i click on safari and i click again on my Window: nothing happens, the mouseDown doesn't occur. I have to click again so the mouseDown event is triggered. How can i force my NSWindow to be

Centering Windows on screen

怎甘沉沦 提交于 2019-12-22 05:28:15
问题 Short and sweet: How can I tell Interface Builder to center a window on a user's screen? I've seen the positioning tool on the inspector, but eyeballing doesn't always land as squarely as I like. Is this something where I should switch over to Xcode and add something to the init or awakeFromNib methods? 回答1: You could use [window center] as answered by wahkiz, but that might not be exactly what you want. The documentation states that this will put the window centered horizontally, but

Mac OS X, make a window go over menu bar

♀尐吖头ヾ 提交于 2019-12-22 05:13:37
问题 Is it possible to make a window to go over the menu bar, without going in fullscreen? Thanks in Advance! 回答1: Yes, trivially: window.level = NSMainMenuWindowLevel + 1; (Reference: Drawing to the Full Screen, OpenGL Programming Guide for Mac OS X .) sebastianmarkow is correct in that this is terrible behaviour for a normal document window, but there are several window types for which this is normal: cursors, tool tips, and special utilities like Xscope. 回答2: I liked Jens Ayton's answer, but

Quit app when NSWindow closes

自古美人都是妖i 提交于 2019-12-22 04:04:15
问题 How correctly to quit the Mac OS X app, when the main (the only one) closes? I know there a method - (void)windowWillClose:(NSNotification *)notification in NSWindowDelegate . But it isn't quite suitable in my case, because it is called before NSWindow closes. 回答1: You cannot have windowDidClose event since the notification that accompanies it would be holding an invalid object (the window is likely to have been deallocated on close). To achieve what you need, make your class the delegate of

How to get notified when NSWindow closes

天大地大妈咪最大 提交于 2019-12-22 02:20:26
问题 how can I take notice when an NSWindow should or will get closed? I'd like to have something like the windowWillClose. Unfortunately NSWindowController does not have as much convenient methods as UIViewController has, for example. So what's the best practice to do that? Thanks –f 回答1: According to the NSWindow docs, a window will post a NSWindowWillCloseNotification notification when it is about to close. Your controller can observe this notification. 来源: https://stackoverflow.com/questions