nswindow

How to show a window without stealing focus on macOS?

限于喜欢 提交于 2019-12-03 00:45:51
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? 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 application, which is what I suspect Spotlight is probably doing. I can achieve this like so: Set LSUIElement to YES

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

你。 提交于 2019-12-02 23:53:42
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 *overlayWindow = [[NSWindow alloc] initWithContentRect:windowRect styleMask:NSBorderlessWindowMask backing

Resizing NSWindow to fit child NSView

眉间皱痕 提交于 2019-12-02 21:28:27
I have one main NSWindow which is empty, and 5 NSViews. The NSViews have different buttons and labels etc, and the window is empty. The first view displayed is a menu, linking to the other views and back. This works fine and the views switch well. However if the NSWindow is a certain size, and the NSView is bigger, then it spills out of the NSWindow and gets cut off. Is there any way such that when I do: [_window setContentView: theNewView]; to also have _window resize to fit the new view? If this is possible, can this be done with an animation? -[NSWindow setContentSize:] does this (without

Set NSWindow Size programmatically

余生长醉 提交于 2019-12-02 20:40:41
How can I set the window size programmatically? I have a window in IB and I want to set the size of it in my code to make it larger. Use -setFrame:display:animate: for maximum control: NSRect frame = [window frame]; frame.size = theSizeYouWant; [window setFrame: frame display: YES animate: whetherYouWantAnimation]; Note that window coordinates are flipped from what you might be used to. The origin point of a rectangle is at its bottom left in Quartz/Cocoa on OS X. To ensure the origin point remains the same: NSRect frame = [window frame]; frame.origin.y -= frame.size.height; // remove the old

Creating a custom title bar on a standard NSWindow

时光毁灭记忆、已成空白 提交于 2019-12-02 19:43:13
I've been trying to build a specific look for my menubar app. I've been using a NSWindow with a NSBorderlessWindowMask style mask and setting [window setOpaque:NO] and [window setBackgroundColor:[NSColor clearColor]] . That gives me a blank canvas which works great for the title bar. Now I'm having problems with the view-based NSTableView I'm using for the listing. How can I clip the NSTableCellView s to the window's rounded corners? I started out just having a custom view wrapping the NSTableView , drawing the background with rounded corners. Using [view addClip:path] doesn't clip child views

How to Highlight the active window and dim the rest windows cocoa app programmatically?

故事扮演 提交于 2019-12-02 18:11:55
问题 In my Cocoa app I want to Highlight which ever the window is active and dim the rest windows. something like window focus application. Below block is my code. NSNotificationCenter* center = [[NSWorkspace sharedWorkspace] notificationCenter]; [center addObserver:self selector:@selector(newApplicationDidActive:) name:NSWorkspaceDidActivateApplicationNotification object:nil]; - (void)newApplicationDidActive:(NSNotification *)notification { NSDictionary* userInfo = notification.userInfo; NSLog(@

How to Highlight the active window and dim the rest windows cocoa app programmatically?

社会主义新天地 提交于 2019-12-02 07:49:00
In my Cocoa app I want to Highlight which ever the window is active and dim the rest windows. something like window focus application. Below block is my code. NSNotificationCenter* center = [[NSWorkspace sharedWorkspace] notificationCenter]; [center addObserver:self selector:@selector(newApplicationDidActive:) name:NSWorkspaceDidActivateApplicationNotification object:nil]; - (void)newApplicationDidActive:(NSNotification *)notification { NSDictionary* userInfo = notification.userInfo; NSLog(@"did Active %@", [userInfo objectForKey:NSWorkspaceApplicationKey ] if ([[NSUserDefaults

NSWindow restorable not always working

梦想的初衷 提交于 2019-12-01 17:39:35
I have checked the restorable option on my NSWindow When I move my application and change its size and close/reopen my application it sets the window size and position to the last size and position but this doesn't happen on every computer where i test it. it only happens to a few computers they don't have special settings regarding the resume. Does anybody have any experience with this? But this doesn't happen on every computer where I test it. It only happens to a few computers. They don't have special settings regarding the resume. Actually, they do. Take a look into the System Preferences

Cocoa: I've got my user's input - Now what?

一个人想着一个人 提交于 2019-12-01 14:22:47
In a nutshell what my program does is: it executes and takes user input periodically using nswindow (which is controlled by my NSWindowController object) and continues execution. here is my myController.mm which is calling and showing the window to take user input: EncryptPasswordDlgController encPassController = [[EncryptPasswordDlgController alloc] init]; [encPassController showWindow:self]; NSString *inputPassword = [encPassController password]; here is my nswindowcontroller object code: #import "EncryptPasswordDlgController.h" @implementation EncryptPasswordDlgController -(id) init {

Passing Click Through Transparent Window

空扰寡人 提交于 2019-12-01 13:30:51
I have a fullscreen transparent window. When the user clicks on it I want the click to be sent to what's underneath the window. How would I do so? Setting IgnoresMouseEvents to YES should do the trick.. (void)setIgnoresMouseEvents:(BOOL)ignoreMouseEvents Specifies whether the window is transparent to mouse clicks and other mouse events, allowing overlay windows. http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindow_Class/Reference/Reference.html#//apple_ref/occ/instm/NSWindow/setIgnoresMouseEvents : 来源: https://stackoverflow.com/questions