nswindow

how to move NSWindow to a particular screen?

房东的猫 提交于 2019-11-29 21:41:51
问题 In my app I need to be able to move my app's windows between the screens programmatically. I'm working on my MacBookPro and I'm connected to DELL monitor. So what I want to do is to have a method that would move my app's window from my laptop screen to the external DELL one. Does anyone know how to achieve it? Any help is highly appreciated! 回答1: [NSScreen screens] gives you an array of NSScreens. The screen at index 0 is the one that's got your menu on. So pick the other screen from the

How to change the height of an NSWindow titlebar?

徘徊边缘 提交于 2019-11-29 21:08:35
I want to change the height of an NSWindow titlebar. Here are some examples: And… I could use an NSToolbar, but the problem is that I can't place views very height (For example: I can't place the segmentedControl higher than in the picture because there is still the titlebar) If I remove the titlebar I can't place a NSToolbar and the window isn't movable. Have you any ideas? INAppStoreWindow is a NSWindow subclass, it tell you how to change the height of title bar. https://github.com/indragiek/INAppStoreWindow http://iloveco.de/adding-a-titlebar-accessory-view-to-a-window/ This example tells

Resize NSWindows with easing animation

一世执手 提交于 2019-11-29 21:06:09
I'm trying to resize an NSWindow (the main one) with a nice easing animation (EaseOut). I can use the [NSWindow animator] but I havn't found a way to add the easing effect. Do you have an idea or code sample which can help me to do that? Anne Option 1 float Y = 100; float X = 200; NSRect frame = [window frame]; frame.origin.y -= Y; frame.size.height += Y; frame.size.width += X; [window setFrame:frame display:YES animate:YES]; Option 2 float Y = 100; float X = 200; NSRect frame = [window frame]; frame.origin.y -= Y; frame.size.height += Y; frame.size.width += X; NSDictionary *windowResize = @{

How to give NSWindow a shake effect as saying NO, as in Login failure window

杀马特。学长 韩版系。学妹 提交于 2019-11-29 20:58:52
问题 I use below code for shake a view and it works properly,now i want to shake a window i change two line that i bolded in code with code2 but doesn't work //-------- code 1 CGFloat DegreesToRadians(CGFloat degrees) { return degrees * M_PI / 180; } NSNumber* DegreesToNumber(CGFloat degrees) { return [NSNumber numberWithFloat: DegreesToRadians(degrees)]; } --------------- [self.view setWantsLayer:YES]; CAKeyframeAnimation * animation= [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation

NSWindow with round corners and shadow

前提是你 提交于 2019-11-29 20:39:09
I'm trying to crate a NSWindow without title bar ( NSBorderlessWindowMask ) with round corners and a shadow, similar to the below "Welcome to Xcode" window. I make a subclass of NSWindow : @implementation FlatWindow - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag { self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:bufferingType defer:flag]; if ( self ) { [self setOpaque:NO]; [self setBackgroundColor:[NSColor clearColor]]; [self setMovableByWindowBackground:TRUE]; [self

Converting an NSPoint from window coordinates to view coordinates

主宰稳场 提交于 2019-11-29 11:53:24
问题 My application has a custom view that displays a timeline of events. This view is wrapped in an NSScrollView to support horizontal scrolling of the timeline. Using notifications, I've implemented a mechanism that should show another custom view which displays detail information about an event when the user clicks that event in the timeline. Below is the code that handles the event when it is received by the timeline: NSEvent *anEvent = [aNotification object]; NSPoint aLocationInSelf = [self

Hide MAAttachedWindow when clicking outside

最后都变了- 提交于 2019-11-29 02:44:15
I'm using an MAAttachedWindow to display a custom window under a NSStatusItem in the Menubar. Everything works fine, but I can't find an easy way to hide it when the user clicks outside of the window. I want to implement this behavior because it's what the user expects. This is the code used to display the MAAttachedWindow : - (void)toggleAttachedWindowAtPoint:(NSPoint)pt { if (!self.attachedWindow) { self.attachedWindow = [[MAAttachedWindow alloc] initWithView:logView attachedToPoint:pt inWindow:nil onSide:MAPositionBottom atDistance:5.0]; [self.attachedWindow setLevel:kCGMaximumWindowLevel];

Allow click and dragging a view to drag the window itself?

元气小坏坏 提交于 2019-11-29 02:16:34
问题 I'm using a textured window that has a tab bar along the top of it, just below the title bar. I've used -setContentBorderThickness:forEdge: on the window to make the gradient look right, and to make sure sheets slide out from the right position. What's not working however, is dragging the window around. It works if I click and drag the area that's actually the title bar, but since the title bar gradient spills into a (potentially/often empty) tab bar, it's really easy to click too low and it

Showing a modal NSWindow, without activating the other application windows

人走茶凉 提交于 2019-11-29 00:08:27
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, the rest of the application's windows also are made active. This is undesirable, as the user then has

Get ALL views and subview of NSWindow

心不动则不痛 提交于 2019-11-28 23:36:27
Is there a way I can get ALL the views and subviews and subviews of these subviews (you get the idea...) of an NSWindow? Thanks. Here is a category on NSView: @interface NSView (MDRecursiveSubviews) - (NSArray *)allSubviews; @end @implementation NSView (MDRecursiveSubviews) - (NSArray *)allSubviews { NSMutableArray *allSubviews = [NSMutableArray arrayWithObject:self]; NSArray *subviews = [self subviews]; for (NSView *view in subviews) { [allSubviews addObjectsFromArray:[view allSubviews]]; } return [[allSubviews copy] autorelease]; } @end With a quick nib file I created with a view hierarchy,