nsview

Dynamically resize NSWindow based on NSOutlineView height

旧时模样 提交于 2019-12-07 20:53:55
问题 I have read many answers to questions about dynamically resizing NSWindows and nothing has quite worked yet. I have built a 'popover' like window to be displayed form the menu bar, I couldn't use NSPopover because it isn't quite customisable enough in terms of design. My view hierarchy current looks like this: NSWindow Subclass - NSView (clears the titlebar rendering, draws popover arrow) - NSView (contentView) - NSOutlineView (main table of content) - NSView (window footer) What I need is

Clear NSView programmatically in swift

99封情书 提交于 2019-12-07 19:49:46
问题 I have a NSView connected to a custom class. There's some drawing on that view: class LineDrawer: NSView { var linear = NSBezierPath() var storage = NSUserDefaults.standardUserDefaults() override func drawRect(dirtyRect: NSRect) { var color = NSColor() if let newLoadedData = storage.objectForKey("color") as? NSData { if let currentColor = NSUnarchiver.unarchiveObjectWithData(newLoadedData) as? NSColor { color = currentColor } } color.set() linear.lineWidth = CGFloat(storage.integerForKey(

Cocoa NSView blurred background

不问归期 提交于 2019-12-07 19:21:19
问题 I know it's possible to create transparent windows in Cocoa, although is it possible to blur whatever is behind it? I know there's been similar questions, but they deal more blurring what is within the actual NSView, not what is behind it. Is this even possible, and If so what method would I need to look into? Possible Impossible? 回答1: In order to answer you, yes its Possible. If you want that effect, check out this GitHub Project I created. I subclassed NSWindow in order to disable opacity

How do you initialize a NSCollectionViewItem?

假装没事ソ 提交于 2019-12-07 18:55:05
问题 I am trying to setup an NSCollectionView that has custom drawing in the individual NSCollectionViewItem views. I have an image that I need to draw in each view, but I cannot link the view back to the NSCollectionViewItem subclass in Interface Builder. Is there an init method I can use with my NSCollectionViewItem in order to perform initialization operations? I tried to implement copyWithZone, but I was doing something wrong because I got some eternal loop. Currently, the only opportunity I

cocoa — getting nested NSViews and CALayers to resize proportionally

跟風遠走 提交于 2019-12-07 17:47:45
问题 My NSWindow's contentView is an NSView subclass. It has some other NSView subclasses as subviews. The subviews are layer-based, and those layers in turn contain sublayers. Some of the sublayers have further sub-sublayers. I want the whole thing to resize proportionally when the window is resized. What is the right way to set it up so that will happen? Thanks EDIT: I am not using Interface Builder at all. 回答1: Here's what I've done to get the contents of an NSView to scale proportionally as I

Graying out an NSWindow's content

可紊 提交于 2019-12-07 16:31:13
问题 I have an NSWindow with 2 NSViews (an NSSplitView and a custom NSView ). Accessing the data to populate these views can take some time. During this period, I'd like to gray out the content of these views. My first approach was to have a black third NSView that covered the other 2 and achieve the graying out effect by changing its alpha value. However I've since learned having a hierarchy with sibling views is undefined. What is the best approach here? Cache the NSBitmapImageRep of the 2 views

WebView (OSX) not rendering in print panel preview

北城余情 提交于 2019-12-07 15:29:07
问题 My app creates and prints a WebView. The output page is being assembled and printed properly, but I do not get a preview of the page in the Print Panel. NSRect printViewFrame = {}; printViewFrame.size.width = paperSize.width - marginLR*2; printViewFrame.size.height = paperSize.height - marginTB*2; WebView *printView = [[WebView alloc] initWithFrame: printViewFrame frameName:@"printFrame" groupName:@"printGroup"]; [printView setShouldUpdateWhileOffscreen: YES]; // use the template engine to

keyUp event heard?: Overridden NSView method

浪子不回头ぞ 提交于 2019-12-07 14:41:02
问题 UPDATED: I'm now overriding the NSView keyUp method from a NSView subclass set to first responder like below, but am still not seeing evidence that it is being called. @implementation svsView - (BOOL)acceptsFirstResponder { return YES; } - (void)keyUp:(NSEvent *)event { //--do key up stuff-- NSLog(@"key up'd!"); } @end --ORIGINAL POST-- I'm new to Cocoa and Obj-C and am trying to do a (void)keyUp: from within the implementation of my controller class (which itself is of type NSController). I

How to receive keyboard events for a NSView after exiting fullscreen mode?

我怕爱的太早我们不能终老 提交于 2019-12-07 06:11:07
问题 I subclass an NSView and start full screen mode when the application finished launching. The view is available as the property fooView in the application delegate. // AppDelegate.m - (void)applicationDidFinishLaunching:(NSNotification*)notification { [[self window] makeKeyAndOrderFront:self]; [[self fooView] enterFullScreenMode:[NSScreen mainScreen] withOptions:nil]; } The class FooView itself implements the following functions. // FooView.m - (void)keyDown:(NSEvent*)event { NSLog(@"%@ %@ - %

Layer-backed NSView performance with rendering directly in CALayer.drawInContext:

倖福魔咒の 提交于 2019-12-07 06:03:04
问题 I have many layer-backed views contained in a NSScrollview and am predominantly concerned with scrolling performance . The documentView and higher are layer-backed hence their subviews are also layer-backed. The following are the three natural places that display/rendering code could go: override NSView.wantsUpdateLayer to return false (or don't do anything because this is the default) & do drawing in NSView's drawRect method override NSView.wantsUpdateLayer to return true & do drawing in