nswindow

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

一个人想着一个人 提交于 2019-12-06 00:16:35
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. This is now possible via the View Debugging features of Xcode. To use this: Start the target app running as you normally would Launch Xcode, and open a

How to show a NSPanel as a sheet

十年热恋 提交于 2019-12-05 22:52:41
问题 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

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

对着背影说爱祢 提交于 2019-12-05 22:15:57
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's why I use the [[NSApp currentEvent] window].frame.origin.y/x to get the location of the status bar

Cocoa - NSWindow animation when displayed?

回眸只為那壹抹淺笑 提交于 2019-12-05 18:57:56
How would I add some sort of CoreAnimation effect when showing a simple nswindow? Thanks I've done an animation like you describe before. However, it wasn't an easy task. Since your animation extends outside the bounds of the window itself, you'll need to render the animation in an oversized, transparent window. When the animation completes, you can order in the real window and remove the transparent one. You'll need an image of the window to use as the content of your animation, so what I would do is order the window in (and probably make it the key window, too, so that it looks focused), but

Graying out an NSWindow's content

眉间皱痕 提交于 2019-12-05 18:31:00
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, then replace them with the 3rd view, using the cached image(s) as background Set the alpha value for

How can I implement gesture recognizers in OS X?

烂漫一生 提交于 2019-12-05 17:48:11
问题 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

NSPopOver & NSViewController - Drag to resize

﹥>﹥吖頭↗ 提交于 2019-12-05 16:16: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. I finally got it working by using Mouse Events . Just need to monitor the override func mouseDown(theEvent: NSEvent) {} override func mouseDragged

Open NSWindowController from NSMenu

帅比萌擦擦* 提交于 2019-12-05 15:06:57
I'm with a NSMenu in an agent application (without the icon in the dock) . When a button from this menu is tapped, I want to show a generic NSWindowController. My menu button action: - (IBAction)menuButtonTapped:(id)sender { MyWindowController *myWindow = [[MyWindowController alloc] initWithWindowNibName:@"MyWindowController"]; [myWindow showWindow:nil]; [[myWindow window] makeMainWindow]; } But the window just "flashes" in the screen (it shows and disappears really fast). Any solution? The reason the window is showing up for a split second and then disappearing has to do with ARC and how you

Main NSWindow shadow doesn't change like child windows

拥有回忆 提交于 2019-12-05 13:56:48
The primary window in my app is borderless: [self.window setStyleMask:NSBorderlessWindowMask]; From that window, I also open other child windows. When I click around between those other child windows I see the drop shadow of those child windows get darker/larger when that child window gets clicked and becomes the focused window. However, my main window's shadow doesn't change when it loses or gains focus. So, there isn't much user feedback to tell them that original primary window has become the focus again. Do I need to override something in my borderless window subclass to enable the shadow

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

佐手、 提交于 2019-12-05 11:01:44
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 always active so i don't have to click it 2x to trigger the mouseDown when i click on a background app and