nswindow

How to use NSWindowDidExposeNotification

不羁的心 提交于 2019-12-08 06:47:48
问题 I am trying to update another windows when the one becomes visible. So I found the NSWindowDidExposeNotification and tried to work with it, so I wrote in my awakeFromNib: // MyClass.m - (void)awakeFromNib { NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; [nc addObserver:self selector:@selector(mentionsWindowDidExpose:) name:NSWindowDidExposeNotification object:nil]; } and implemented the method // MyClass.h - (void)mentionsWindowDidExpose:(id)sender; // MyClass.m - (void

capture hidden NSWindow

人盡茶涼 提交于 2019-12-08 06:03:42
问题 I'm able to capture NSWindow s which are visible using code simular to the SonOfGrab Example But how can I capture a hidden NSWindow ? Or what is the way to hide a NSWindow from the user but to still appear in de Windowserver? Thanks in advance! 回答1: It isn't possible to capture the contents of an NSWindow which isn't visible on-screen. When a window is minimized/hidden/whatever, the visual representation is dropped to save memory. (Not sure on exactly how this is managed, feel free to chime

How can I move application's window between virtual desktops in OS X?

旧街凉风 提交于 2019-12-08 05:50:34
问题 I would like to move my application's window between OS X virtual desktops. For example: to move window to currently active desktop. Is there a way to do it with Swift? 回答1: I have found answer by my self. This could be done by adjusting window behaviour. let window = NSWindow... Window is shown on all virtual desktops: window.collectionBehavior = NSWindowCollectionBehavior.CanJoinAllSpaces Window follows active virtual desktop: window.collectionBehavior = NSWindowCollectionBehavior

Create Drop Shadow for NSView - Cocoa

﹥>﹥吖頭↗ 提交于 2019-12-08 04:39:12
问题 I'm trying to create a drop shadow surrounding the NSView like how NSWindow does it with its shadow, but I'm having some difficulty. I created a class for the NSView I'm creating the drop shadow for and I'm using this code for the overriding method: -(void)drawRect:(NSRect)dirtyRect { NSRect rect = NSInsetRect([self bounds], 10.0, 10.0); NSShadow *dropShadow = [[[NSShadow alloc] init] autorelease]; [dropShadow setShadowColor:[NSColor blackColor]]; [dropShadow setShadowBlurRadius:5];

Make borderless window with darker larger shadow

跟風遠走 提交于 2019-12-08 03:16:26
How to create darker and larger shadow when window becomes active in borderless window? I subclassed NSWindow and my window becomes main window and key window but that's not helping.. shadow still small. So maybe someone knows how to fix this? I also tried invalidate shadow, but that didn't help too.. Subclassed NSWindow: - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag { self = [super initWithContentRect: contentRect styleMask: NSBorderlessWindowMask backing: NSBackingStoreBuffered defer: NO]; if(self) {

Dynamically resize NSWindow based on NSOutlineView height

旧时模样 提交于 2019-12-07 20:53:55
问题 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

Graying out an NSWindow's content

可紊 提交于 2019-12-07 16:31:13
问题 I have an NSWindow with 2 NSViews (an NSSplitView and a custom NSView ). Accessing the data to populate these views can take some time. During this period, I'd like to gray out the content of these views. My first approach was to have a black third NSView that covered the other 2 and achieve the graying out effect by changing its alpha value. However I've since learned having a hierarchy with sibling views is undefined. What is the best approach here? Cache the NSBitmapImageRep of the 2 views

Minimize / miniaturize cocoa NSWindow without titlebar

倖福魔咒の 提交于 2019-12-07 12:44:20
问题 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

how to traverse window/view hierarchy of other application in OS X?

时光总嘲笑我的痴心妄想 提交于 2019-12-07 11:54:11
问题 I am trying to figure out how to get(read only) entire window/view hierarchy of any application. I get list of all open windows using "CGWindowListCopyWindowInfo" . It also returns window number( "kCGWindowNumber" ). It also shows sharing status of root window by "kCGWindowSharingState = 1;" . Now, I want to check that a particular window/view present in hierarchy of that application. I got kCGWindowNumber which is root window of application. 回答1: This is now possible via the View Debugging

NSPopOver & NSViewController - Drag to resize

﹥>﹥吖頭↗ 提交于 2019-12-07 10:17:10
问题 I am making a MenuBar app for which I am using NSPopOver . The problem is that NSPopover uses NSViewController as a contentViewController , whose size gets fixed. My requirement is to make the size of NSViewController flexible i.e just like NSWindowController (set the minimum size and maximum depends upon the total screen size). In simple words how to change the size of NSViewController(NSPopOver) when user drags it. I am new to OS X programming. 回答1: I finally got it working by using Mouse