nswindow

Disable window stretching Cocoa?

折月煮酒 提交于 2019-11-30 17:52:09
How do I disable the stretching of the window at the bottom right? I would have to deal with auto-sizing and all that stuff, which would be unnecessary if I simply didn't allow the user to stretch the window size. First you should set the maximum width/height equal to the minimum width/height in IB: Then you can disable the resize control by unchecking "Resize" in IB: Select the window in Interface Builder and uncheck the "Resize" checkbox in the Attributes Inspector panel 来源: https://stackoverflow.com/questions/7734503/disable-window-stretching-cocoa

Keep NSWindow front

折月煮酒 提交于 2019-11-30 17:39:26
I open a NSWindow from my main NSWindow. DropHereWindowController *dropHereWindowController = [[DropHereWindowController alloc] initWithWindowNibName:@"DropHereWindow"]; [dropHereWindowController showWindow:nil]; I want this window to stay on top of my main window when dragging a file from the finder to that "DropHereWindow". However when opening the finder (not having the focus any longer) my "DropHereWindow" goes behind my main window. I tried orderFront, makeKey, makeKeyAndFront but nothing helped. What can I do about it? Method: - (void)setLevel:(NSInteger)windowLevel Sub-class the

How to know if a NSWindow is fullscreen in Mac OS X Lion?

早过忘川 提交于 2019-11-30 17:31:05
I guess I should check if [NSApplication presentationOptions] contains NSFullScreenModeApplicationPresentationOptions , but how do I achieve that? EDIT: using [NSApplication presentationOptions] doesn't work as in my document-based app there might be some documents in fullscreen and others not. I'm now looking for another solution. I'm wondering why there isn't a property called [NSWindow isFullscreen] or something like that. I was just looking for a solution myself and based on Matthieu's answer I created a category on NSWindow that works fine for me. @interface NSWindow (FullScreen) - (BOOL

Change mouse cursor over inactive NSWindow

独自空忆成欢 提交于 2019-11-30 15:40:38
I have subclassed NSWindow and I have a MYWindow class implementing the following method: -(void)resetCursorRects { NSImage *image = [NSImage imageNamed:@"cursor.png"]; [image setSize:NSMakeSize(32, 32)]; NSCursor *cursor = [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint(1, 1)]; [super resetCursorRects]; [self addCursorRect:[self bounds] cursor:cursor]; } This will change the cursor for the whole window and I will see cursor.png instead of the default mouse pointer. The problem is that this only works if the MYWindow is set to the key window which is of course non trivial to make it.

Make NSView in NSPanel first responder without key window status

家住魔仙堡 提交于 2019-11-30 15:34:24
Is it possible to give an NSView inside an NSPanel first responder status without giving the NSPanel key window status (making the main application window resign key)? Thanks. Well, I ended up figuring this one out, but it took a lot of research so I'll post the details here in case anyone else runs into the same problem. First of all, a few basics: It's impossible to have 2 windows actually be key at the same time It's possible to fake a window into thinking it's key by overriding -isKeyWindow but that won't give the views contained in the window first responder status. My Scenario: I added a

how to move NSWindow to a particular screen?

为君一笑 提交于 2019-11-30 15:23:27
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! [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 array, find it's 'visibleRect' and change the frame of your window to go inside it. 来源: https://stackoverflow

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

强颜欢笑 提交于 2019-11-30 14:23:44
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.z"]; [animation setDuration:0.04]; [animation setRepeatCount:10]; srand([[NSDate date]

Closing Mac application (clicking red cross on top) and reopening by clicking dock icon

≯℡__Kan透↙ 提交于 2019-11-30 12:33:25
When I close my Mac application (by clicking red cross button on window top bar) the app icon stays in the dock at the bottom. Now this is normal behaviour. When user click on it again it does not fire up the application unless the user quits the application altogether and relaunches it again. A similar example on Mac OS X is "Activity Monitor". You can close the application by clicking the red cross button at the top the but dock icon stays there. User can re-open it by clicking dock icon. How can I achieve this in my own application ? If you are still concerned how to reopen the window that

How do you use the dark vibrancy on an NSWindow?

六眼飞鱼酱① 提交于 2019-11-30 12:21:17
问题 What is the correct way to use the Vibrant Dark ( NSAppearanceNameVibrantDark ) or Vibrant Light ( NSAppearanceNameVibrantLight ) modes with an NSWindow ? I'm building an application and would like to offer the new Vibrant Dark appearance as an option for the main application's NSWindow . The window itself is a pretty straight forward window with an NSToolbar across the top and a scroll view as the main content area. There's plenty of information from Apple on using the new vibrancy

Converting an NSPoint from window coordinates to view coordinates

拈花ヽ惹草 提交于 2019-11-30 08:35:05
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 convertPoint: [anEvent locationInWindow] toView: self]; // Create callout view and display NSRect aRect