nsview

CGImage recording distortion

自作多情 提交于 2020-06-27 12:51:08
问题 I've written a helper class to record a NSView and save it to a QuickTime file. The view is recorded fine to a QuickTime movie but the output is skewed for some reason. The core of my class is below, and the output is this: - (void) captureImage { [self getCGImageFromView]; pixelBuffer = [self getPixelBufferFromCGImage:viewCGImage size:CGRectMake(0, 0, mViewRect.size.width, mViewRect.size.height).size]; if(pixelBuffer) { if(![adapter appendPixelBuffer:pixelBuffer withPresentationTime

Layer backed NSView with custom CALayer not calling updateLayer?

柔情痞子 提交于 2020-06-10 02:41:37
问题 I have a custom layer-backed NSView and have overidden the makeBackingLayer method to return a custom CALayer subclass. I have also overriden wantsUpdateLayer to return true thereby fully opting into layer-like drawing. override func makeBackingLayer() -> CALayer { return Layer() // my custom class with "drawLayer:" implemented } override var wantsUpdateLayer:Bool{ return true } // never called override func updateLayer() { super.updateLayer() println("updateLayer after") self.layer?

Layer backed NSView with custom CALayer not calling updateLayer?

独自空忆成欢 提交于 2020-06-10 02:41:28
问题 I have a custom layer-backed NSView and have overidden the makeBackingLayer method to return a custom CALayer subclass. I have also overriden wantsUpdateLayer to return true thereby fully opting into layer-like drawing. override func makeBackingLayer() -> CALayer { return Layer() // my custom class with "drawLayer:" implemented } override var wantsUpdateLayer:Bool{ return true } // never called override func updateLayer() { super.updateLayer() println("updateLayer after") self.layer?

WKWebView Won't Load (NSViewController, OS X)

删除回忆录丶 提交于 2020-05-14 17:18:42
问题 I am trying to build a simple WKWebView application that will display Google in the WebView. The app works perfectly fine; however, upon implementing the WKWebView, the app no longer shows a window. It just simply launches the app (in the dock) with no NSView in sight. ViewController.swift import Cocoa import WebKit class ViewController: NSViewController { var webView: WKWebView? override func loadView() { self.webView = WKWebView() self.view = self.webView! let url = NSURL(string:"http://www

Show NSPopover from NSToolbarItem Button

余生颓废 提交于 2020-05-10 09:46:04
问题 I want to show an NSPopover from an NSToolbarItem button in my toolbar. (i.e. positioned below the button). Ideally, I want to pass the NSView of the button to the popover to position it. My question is, how do I get the NSView of the NSToolbarItem ? [toolbarbutton view] always returns nil. 回答1: The answer appears to be in the video for the 2011 WWDC Session 113, "Full Screen and Aqua Changes." Basically, put an NSButton inside the NSToolbaritem and use the view of that. A blog post is here:

Show NSPopover from NSToolbarItem Button

与世无争的帅哥 提交于 2020-05-10 09:45:12
问题 I want to show an NSPopover from an NSToolbarItem button in my toolbar. (i.e. positioned below the button). Ideally, I want to pass the NSView of the button to the popover to position it. My question is, how do I get the NSView of the NSToolbarItem ? [toolbarbutton view] always returns nil. 回答1: The answer appears to be in the video for the 2011 WWDC Session 113, "Full Screen and Aqua Changes." Basically, put an NSButton inside the NSToolbaritem and use the view of that. A blog post is here:

NSView loses mouseMoved/mouseDragged if dragged in from subview

拜拜、爱过 提交于 2020-04-11 04:23:07
问题 A = the parent NSView; B = the child NSView; B has a small NSTrackingArea; B is a small subview of A; A correctly receives mouseMoved and mouseDragged events if moved,clicked, dragged in a empty area. If i click in B and drag the mouse outside of its bounds into A, A does not receive any mouseMoved or mouseDragged events. Can someone point me to what i could do to get the superview A to react to this drag? 回答1: I've observed this and I was able to solve it by doing as follows: Create a

Why my MTKview is drawn like if there is a dark overlay on the top of it?

梦想与她 提交于 2020-02-21 06:49:04
问题 I'm under macOS and I create an MTKView , and I set this MTKView as a subview of the ContentView of my NSWindow . when I'm inside my MTKView.drawRect method and when I call NSView(Super).getRectsBeingDrawn it returns me nothing! why? But my main problem is that the MTKView is drawn darker (like there is something darker on the top of it) I must have something like this instead: Any idea what can cause this darker effect? 来源: https://stackoverflow.com/questions/60057910/why-my-mtkview-is-drawn

NSView overlay passes mouse events to underlying subviews?

你。 提交于 2020-01-25 06:18:11
问题 I have a loading overlay which is supposed to block all the AppKit Controls off untill loading is done. However the view seems to be passing all the mouse events to the underlying layers. How to disable that? 回答1: I suggest using a child window instead. 来源: https://stackoverflow.com/questions/3522410/nsview-overlay-passes-mouse-events-to-underlying-subviews