nswindow

NSWindow launching with wrong size after setting contentViewController to NSTabViewController

爱⌒轻易说出口 提交于 2019-12-03 16:20:12
I have an Xcode project with an NSWindowController whose contentViewController was set to a subclass of NSViewController . I recently removed the NSViewController subclass from the storyboard and replaced the contentViewController with an NSTabViewController subclass. Now, when I run the application, the NSWindow opens with a size of 500x500 instead of the size of the first tab. What's more, there is no view I can see in the storyboard that has a size of 500x500, and that size isn't being programmatically, either. The window itself is set to a different size, as is the view in the

Allow views in childWindow to become key without losing focus on parentWindow

牧云@^-^@ 提交于 2019-12-03 15:24:30
I added a childWindow of a custom subclass of NSWindow to a parentWindow (also a custom subclass of NSWindow). The childWindow has the NSBorderlessWindowMask and canBecomeKeyWindow: is overridden to return YES and canBecomeMainWindow: to return NO. The childWindow is set to resize with the parentWindow. So I want to create the illusion that the views of the childWindow are part of the parentWindow. The main idea is to arrange the document windows created by the document-based application within a main window to provide a tabbed interface (just like in a browser) to switch between the documents

Determine which screen a window is on given the window ID

我们两清 提交于 2019-12-03 14:31:44
问题 Is there a way to get the NSScreen for a window of another process assuming that I have the window id? I got pretty close with the following code, but the info dictionary doesn't say which screen the window is on. CFArrayRef windowArray = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID); NSArray* windowList = (NSArray*)CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID); NSUInteger count = [windowList count]; for (NSUInteger i = 0; i <

Document sheet not responding to keyboard events

吃可爱长大的小学妹 提交于 2019-12-03 10:38:41
I think it's a first responder problem, but I'm not sure. I'm implementing an edit window for data in a table view. Very similar in concept to the UI for editing filter rules in Mail.app. I have an editing window that I attach to my primary window with: [NSApp beginSheet: criteriaEditPanel modalForWindow: [self window] modalDelegate: self didEndSelector: @selector(criteriaEditDidEnd:returnCode:contextInfo:) contextInfo: (void *)[criteriaList objectAtIndex: index]]; The panel displays properly, from the title bar of the main window. I can manipulate the pop-up controls on the panel with the

How to show a window without stealing focus on macOS?

若如初见. 提交于 2019-12-03 10:14:36
问题 I was wondering how could spotlight floating with focus, and another window still has focus! I could easy make a window floating over all other window with window?.level = Int(CGWindowLevelForKey(.maximumWindow)) ,but I cannot let two windows both has focus, help! Is there any function like ShowWithoutActivating in Cocoa? 回答1: I've been playing around with this a bit, and I seem to be able to produce this effect when the frontmost window is not from the same process as the frontmost

The most elegant way of creating a fullscreen overlay on Mac OS X (Lion)?

蹲街弑〆低调 提交于 2019-12-03 09:30:33
问题 I'm searching for the "best" way of creating a fullscreen overlay under Mac OS X. I want to create a transparent or semi-transparent overlay, which cares about mouse events and shows other input/output elements. This overlay should be above every other GUI items (like the CMD-Tab overlay). Do you know how to do it effectively? At the moment I'm playing around with this kind of code: int windowLevel = CGShieldingWindowLevel(); NSRect windowRect = [[NSScreen mainScreen] frame]; NSWindow

How to create a topmost overlay which ignores mouse clicks, etc

ぃ、小莉子 提交于 2019-12-03 08:51:36
I'd like to know how to setup a transparent overlay windown in Cocoa which can ignore mouse clicks (so that they pass through to whatever window is below). The user should not be able to interact with the window with their mouse. Tell it to ignore mouse events. 来源: https://stackoverflow.com/questions/3570247/how-to-create-a-topmost-overlay-which-ignores-mouse-clicks-etc

how to get window with semi-transparent blurred background

倾然丶 夕夏残阳落幕 提交于 2019-12-03 07:23:44
I'd like to get a window that has a semi-transparent blurred background, just like what the Terminal can do. See this video, about 30 sec in, to see what I mean: http://www.youtube.com/watch?v=zo8KPRY6-Mk See an image here: http://osxdaily.com/wp-content/uploads/2011/04/mac-os-x-lion-terminal.jpg I've been googling for an hour, and can't get anything to work. I believe I need to somehow create a core animation layer and add a background filter, but I've been unsuccessful so far... I just see the gray background of my window. Here's the code I've got so far: Code: // Get the content view --

Determine which screen a window is on given the window ID

放肆的年华 提交于 2019-12-03 03:28:38
Is there a way to get the NSScreen for a window of another process assuming that I have the window id? I got pretty close with the following code, but the info dictionary doesn't say which screen the window is on. CFArrayRef windowArray = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID); NSArray* windowList = (NSArray*)CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly, kCGNullWindowID); NSUInteger count = [windowList count]; for (NSUInteger i = 0; i < count; i++) { NSDictionary* nswindowsdescription = [windowList objectAtIndex:i]; NSNumber* windowid =

Why isn't my sheet attached to the window it's run for?

时光毁灭记忆、已成空白 提交于 2019-12-03 01:17:41
I have a NIB which contains two windows, one is the app's main window visible at launch and the other is a custom sheet (and therefore not visible at launch). When the sheet is required my controller calls: [NSApp beginSheet: sheetWindow modalForWindow: mainWindow modalDelegate: self didEndSelector: @selector(didEndSheet:returnCode:contextInfo:) contextInfo: nil]; which displays the sheet window and starts a modal session, but the window has a standard Aqua title bar, is not 'connected' to the main window and can be moved around just like a regular window. Needless to say, this is not