nswindow

How to get a list of all open NSWindow from all running application?

醉酒当歌 提交于 2019-11-27 20:15:59
Is there a way to get list of open or visible NSWindow from mac desktop? Chuck Note that not all windows are necessarily NSWindows , and that NSWindow only provides an interface to windows in your own address space. The supported way to access every window is the CGWindow API. Take a look at the Son of Grab sample code to see how it's done. bosmacs You can use the accessibility API (accessibility must be enabled under System Preferences for it to work) to get information on windows (and other UI elements) from other processes. This question might be just what you're looking for. ALL running

Hide NSWindow title bar

微笑、不失礼 提交于 2019-11-27 20:03:08
问题 Is there a way to hide the titlebar in an NSWindow? I don't want to have to completely write a new custom window. I can't use NSBorderlessWindowMask because I have a bottom bar on my window, and using NSBorderlessWindowMask makes that disappear. I also tried using setContentBorderThickness:forEdge: with NSMaxYEdge and setting it to 0, that didn't work either. Any help is appreciated 回答1: [yourWindow setStyleMask:NSBorderlessWindowMask]; 回答2: Starting from OS X 10.10, you can hide title bar.

How to make a smooth, rounded, volume-like OS X window with NSVisualEffectView?

自闭症网瘾萝莉.ら 提交于 2019-11-27 18:01:48
I'm currently trying to make a window that looks like the Volume OS X window: To make this, I have my own NSWindow (using a custom subclass), which is transparent/titlebar-less/shadow-less, that has a NSVisualEffectView inside its contentView. Here's the code of my subclass to make the content view round: - (void)setContentView:(NSView *)aView { aView.wantsLayer = YES; aView.layer.frame = aView.frame; aView.layer.cornerRadius = 14.0; aView.layer.masksToBounds = YES; [super setContentView:aView]; } And here's the outcome (as you can see, the corners are grainy, OS X's are way smoother): Any

How do I create a Cocoa window programmatically?

岁酱吖の 提交于 2019-11-27 17:12:17
My Cocoa app needs some small dynamically generated windows. How can I programmatically create Cocoa windows at runtime? This is my non-working attempt so far. I see no result whatsoever. NSRect frame = NSMakeRect(0, 0, 200, 200); NSUInteger styleMask = NSBorderlessWindowMask; NSRect rect = [NSWindow contentRectForFrameRect:frame styleMask:styleMask]; NSWindow * window = [[NSWindow alloc] initWithContentRect:rect styleMask:styleMask backing: NSBackingStoreRetained defer:false]; [window setBackgroundColor:[NSColor blueColor]]; [window display]; Jason Coco The problem is that you don't want to

Showing a modal NSWindow, without activating the other application windows

六月ゝ 毕业季﹏ 提交于 2019-11-27 15:11:28
问题 I have an NSStatusItem that is properly displaying in the MenuBar. One of the items (when clicked) displays a modal NSWindow from my application, which is meant to perform a one-off task, then disappear. (Eg. the user enters a small bit of text, clicks "Save", and the modal NSWindow goes away.) The issue occurs when the application is running in the background. The modal window properly appears above whatever application is running in the foreground, but when the user clicks the "Save" button

How to create a transparent window with non-rectangular buttons?

北城余情 提交于 2019-11-27 14:49:27
I am looking to make a custom window which would look something like this (never mind the quick photoshop): The main problem I have is not to make the window transparent (although I guess any info is welcome!), but that I want to be able to click only on the visible part of the buttons. For example, if I click just outside the top left of the "5" button, I want it to register a click on the "1" button and not the "5" button, even though I clicked in button 5's bounding box. And if I click just ouside of the "1" button's top left "corner", I want it to click on whatever is beneath my window and

Keep window always on top?

自作多情 提交于 2019-11-27 11:34:09
In Objective-C for Cocoa Apps it's possible to use such way to keep window always on top? How to achieve the same with Swift? self.view.window?.level = NSFloatingWindowLevel Causes build error Use of unresolved identifier 'NSFloatingWindowLevel' To change the window level you can't do it inside viewDidload because view's window property will always be nil there but it can be done overriding viewDidAppear method or in a IBAction method: Swift 1 override func viewDidAppear() { super.viewDidAppear() view.window?.level = Int(CGWindowLevelForKey(kCGFloatingWindowLevelKey)) } Swift 2 view.window?

How to Change Color of NSWindow Title Bar in OSX

孤人 提交于 2019-11-27 10:23:21
问题 After a Long search regarding the NSWindow title bar color and title color, i have found a easy drawing solution. I posting this to share my knowledge. 回答1: Sub class a NSView with name MyTitleView and add the following code - (void)drawString:(NSString *)string inRect:(NSRect)rect { static NSDictionary *att = nil; if (!att) { NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; [style setLineBreakMode:NSLineBreakByTruncatingTail]; [style setAlignment

Why NSWindow without styleMask:NSTitledWindowMask can not be keyWindow?

心不动则不痛 提交于 2019-11-27 08:08:54
Problem: I have one window mainWindow and another childWindow added to mainWindow . childWindow is kind of WindowExt class. This class I define for catch method call [NSWindow becomeKeyWindow] that must be called after [childWindow makeKeyWindow] . If I create childWindow and try to make it keyWindow on next way: WindowExt *childWindow = [[WindowExt alloc] initWithContentRect:addedWindowRect styleMask:NSBorderlessWindowMask | NSTitledWindowMask backing:NSBackingStoreBuffered defer:NO]; [mainWindow addChildWindow:childWindow ordered:NSWindowAbove]; [childWindow makeKeyWindow]; method [WindowExt

keyDown not being called

拥有回忆 提交于 2019-11-27 06:11:09
问题 I have a custom NSView called SurfaceView. It is the contentView of a NSWindow and it handles basic events like mouse click and drawing. But don't matters what I do, it does not handle the keyDown function. I've already override the acceptsFirstResponder but nothing happens. If it matters, I run the application using a custom NSEvent loop, shown below: NSDictionary* info = [[NSBundle mainBundle] infoDictionary]; NSString* mainNibName = [info objectForKey:@"NSMainNibFile"]; NSApplication* app