nswindow

Any NSWindowRestoration examples?

柔情痞子 提交于 2019-12-21 19:45:29
问题 I'm having some trouble implementing NSWindowRestoration (in 10.7 Lion). I'm not getting the protocol notifications. Is there an example app with this implemented somewhere? I cannot find one on the Apple Developer site. Thanks! Edit: The question marked as answer is helpful, but the problem in my case was that I was using a menubar-only application. I guess window restoration doesn't work with dockless apps yet. Snap! 回答1: The class method + (void)restoreWindowWithIdentifier:(NSString *

How do I create a custom borderless NSWindow in Objective-C + Cocoa?

梦想的初衷 提交于 2019-12-21 18:00:27
问题 Let me start off by saying that this is my first real Cocoa app. It's a simple app that pretty much displays my website in a borderless window. The way I'm currently creating a borderless window is using the following: - (void) awakeFromNib { [window setStyleMask:NSBorderlessWindowMask]; [window setAcceptsMouseMovedEvents:YES]; [window setMovableByWindowBackground:YES]; [window setLevel:NSNormalWindowLevel]; } The problem with this is that as a result, the WebView within the window does not

How show sheet loaded from xib? (MacOSx)

谁说我不能喝 提交于 2019-12-21 17:55:20
问题 I have a xib file with only an NSPanel in it, I'm trying to show this panel as modal sheet (with beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo: ). The file's owner for this xib is a controller class "MyController" which has the IBOutlet to the NSPanel. What I am looking for is something like: ... MyController *controller = [[MyController alloc] init]; [NSApp beginSheet:controller.panel modalForWindow:[NSApp mainWindow] modalDelegate:controller didEndSelector:nil

Programmatically closing an NSWindow when it loses focus

天涯浪子 提交于 2019-12-21 12:29:08
问题 I am making an image picker that will display an n by n grid of selectable button when the picker is popped up. This grid of buttons will be contained within an NSWindow but I would like for the window to be close automatically if the user clicks off the screen. Is there a flag that can be set so that when the window looses focus it will be closed automatically? 回答1: There are two notifications that you may be interested in: NSWindowDidResignKeyNotification and

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

人走茶凉 提交于 2019-12-21 02:50:08
问题 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. 回答1: Tell it to ignore mouse events. 来源: https://stackoverflow.com/questions/3570247/how-to-create-a-topmost-overlay-which-ignores-mouse-clicks-etc

How to receive notifications when moving Window by mouse?

廉价感情. 提交于 2019-12-19 09:46:27
问题 I tried -setFrame:display: and -windowDidMove: but they are not sent while moving window. 回答1: If You want to track NSWindow live moving, it's not possible by default You’ll have to do it on your own. It's possible to get notification when NSWindow is started to drag (move) with NSWindowWillMoveNotification or ended dragging (moving) - NSWindowDidMoveNotification . Take a look at these examples they can help You to solve live window moving problem: 1. Example: Description: Very short category

Keep NSWindow front

て烟熏妆下的殇ゞ 提交于 2019-12-18 19:08:30
问题 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

Change mouse cursor over inactive NSWindow

Deadly 提交于 2019-12-18 16:56:33
问题 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

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

我是研究僧i 提交于 2019-12-18 15:31:33
问题 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 to detect right and left click in cocoa

天涯浪子 提交于 2019-12-18 12:47:36
问题 I want to create a action on right and left click of mouse. Click may be on NSTableViewCell, NSView, etc (Like when we right click on window it gives a pop-up ) . Is there any API to do such task? If no, any other way . Thank you in advance for helping me. 回答1: You have to override NSResponder methods like: - (void) mouseDown: (NSEvent*) theEvent; - (void) rightMouseDown: (NSEvent*) theEvent; Reference: NSResponder Documentation. Update: as mentioned below, NSView and NSTableView inherits