nswindow

Grey border around view when using NSBorderlessWindowMask

有些话、适合烂在心里 提交于 2019-12-11 02:43:37
问题 I'm having the exact same problem as in this question: Gray border when using NSBorderlessWindowMask However, the accepted answer (as in the comments) of removing the window shadow doesn't seem to work, at least on Lion. I've subclassed NSWindow , and created a borderless window in this manner: -(id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag { self = [super initWithContentRect:contentRect styleMask:

How to check if an NSWindow is open

穿精又带淫゛_ 提交于 2019-12-11 01:58:36
问题 I have an NSWindow which can be closed and reopened (I've called [setReleasedWhenClosed: NO] ). How do I check if it is open or closed programmatically? I've read the doc and Googled but can't see a sane way to do this. [isVisible] is deprecated. [occlusionState] isn't what I'm after. I've worked around it using notifications, but I can't believe there isn't some property or method on NSWindow to do this 回答1: You make make of use of screen property of NSWindow. If the window in offscreen it

set NSWindow focused

て烟熏妆下的殇ゞ 提交于 2019-12-10 19:34:41
问题 I have an app winth one window and one panel, attached to this window. steps: deactivate my app (app opened, but without the focus) click on a button on panel (panel is focused now, but main window is not) How to set focus to the main window (parent window) from the panel? 回答1: It is not clear what you mean by focus, and whether what you call main window is a main window as defined in Cocoa. Assuming it is a Cocoa main window and focus is the same as key status, [[NSApp mainWindow]

NSScrollView scroll bars are of the wrong length

为君一笑 提交于 2019-12-10 19:18:15
问题 I have a Cocoa window, whose content view contains an NSScrollView that, in turns, contains a fixed-size NSView. Upon launching the program, the scroll bars displayed initially are too small, as if the content size was much larger than it actually is: When I start playing with, e.g., the vertical scroll bar, and bring it back to the original position at the top, it gets resized to its expected size (which corresponds to the ratio of scroll view and content view sizes): (Notice the horizontal

NSScrollView in a NSWindow

試著忘記壹切 提交于 2019-12-10 17:17:23
问题 I have an NSScrollView inside an NSWindow, but it seems to be disabled. It looks like it would work, but the scrollbars are unresponsive to the mouse or the scroll wheel. When I put the exact same NSScrollView inside a window on a new XCode project, it works perfect. There is something about the way I am making the window that is preventing the scroll from working. I've been able to simplify it to this example: //Make a window NSWindow* myWindow = [[NSWindow alloc] initWithContentRect

Stopping modal when window is closed (Cocoa)

有些话、适合烂在心里 提交于 2019-12-10 16:00:28
问题 I am currently displaying a modal window by using this code: [[NSApplication sharedApplication] runModalForWindow:mainWindow]; However, when I close this window, the other windows are still inactive. How do I run the stopModal method when the window is closed using the "red x"? Thank you, Michael 回答1: You can create a delegate for the window and have it respond to either the -(void)windowWillClose:(NSNotification *)notification or the - (void)windowShouldClose:(NSNotification *)notification

Get NSWindow from kCGWindowNumber

帅比萌擦擦* 提交于 2019-12-10 12:44:46
问题 From k CGWindowNumber , how do I get NSWindow ref. I tried using: [NSApp windowWithWindowNumber:windowNumber] but I always get a null value. I need to get the NSWindow to apply [window setlevel:NSFloatingWindowLevel] , that I have set the always on top of a given window. Does anyone know how to solve this problem or has any alternative solution? Thanks for the answer, but this is not the solution, I had already tried but it does not work, actually I did a test , I tried the following code:

How do I convert Cocoa co-ords from top left == origin to bottom left == origin

风流意气都作罢 提交于 2019-12-08 17:16:52
问题 I use CGWindowListCopyWindowInfo to get a list of all windows. It gives me the co-ordinates of each window based upon the origin being the top-left of the screen. If I use NSWindow's setFrame method, the co-ordinates on based upon the origin being the bottom-left of the screen. What's a clean, reliable way to convert from one to the other? Added: By clean and reliable, I mean, something sure to work regardless whether the user has multiple screens or is using Spaces. I figure there must be a

(NSWindowButton) NSWindow.standardWindowButton button not highlighting

人走茶凉 提交于 2019-12-08 10:43:08
问题 When i use the following to create a button NSWindow.standardWindowButton(NSWindowButton.ZoomButton, forStyleMask: 0) I get a button that doesn't react to mouse hover events. I can augment this by creating a container view with a NSTrackingArea and manually triggering the highlight method but it produces a clicked state. Is there a way to somehow force the button into the expected behavior state without the darkened background? I have been trying to avoid subclassing NSButton , but it seems

Make borderless window with darker larger shadow

蹲街弑〆低调 提交于 2019-12-08 07:37:13
问题 How to create darker and larger shadow when window becomes active in borderless window? I subclassed NSWindow and my window becomes main window and key window but that's not helping.. shadow still small. So maybe someone knows how to fix this? I also tried invalidate shadow, but that didn't help too.. Subclassed NSWindow: - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag { self = [super