nsview

Cocoa NSView blurred background

家住魔仙堡 提交于 2019-12-06 09:45:06
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? 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 and then I added a Background Filter:Gaussian Blur to the NSView using the View Effects Inspector located at

Forwarding drag & drop event to parent view

馋奶兔 提交于 2019-12-06 08:24:48
I have an application where I have one custom view which is derived from NSView. Within this view, there are several custom subviews, which are also derived from NSView. I want to implement a drag and drop behavior which allows URLs to be dropped onto the views. Everything is already working for the main view. So, actually I would have to implement dragging behavior handlers on the child-views and the parent-view class. The thing is, that I don't want to copy the complete handling code to all the child-views to make them also accept drag events. So I thought that it would be the best way to

Dynamically resize NSWindow based on NSOutlineView height

喜欢而已 提交于 2019-12-06 06:40:56
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 for the window to expand and contract with items in the NSOutlineView expanding and contracting, so that

How do you initialize a NSCollectionViewItem?

[亡魂溺海] 提交于 2019-12-06 05:49:07
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 have found to make my connections to the view are after the selection has changed using -(void

Rounded NSView in a Transparent Window

坚强是说给别人听的谎言 提交于 2019-12-06 05:35:21
问题 I'm trying to make a transparent NSWindow with a rounded view in there. I'm trying to have a rounded view with a transparent window. This is what it looks like now: (see the little dots in the corners) Here's another example with the border radius set to 10px (set in NSView drawRect): I am using code from this Apple sample: https://developer.apple.com/library/mac/#samplecode/RoundTransparentWindow/Introduction/Intro.html Specifically this method in my NSWindow subclass: - (id

An NSMenuItem's view (instance of an NSView subclass) isn't highlighting on hover

风流意气都作罢 提交于 2019-12-06 03:54:14
I need to use a custom NSView subclass to draw some content, but it isn't drawing as highlighted when the user hovers and it doesn't dismiss the NSMenu when the user clicks on it. Any ideas? Edit So using -drawRect: and [[self enclosingMenuItem] isHighlighted] I'm able to tell whether or not I need to draw the view as highlighted and am given the chance to do so. All I have to figure out is how to do that. Maybe you should try it this way: #define menuItem ([self enclosingMenuItem]) - (void) drawRect: (NSRect) rect { BOOL isHighlighted = [menuItem isHighlighted]; if (isHighlighted) { [[NSColor

WebView (OSX) not rendering in print panel preview

匆匆过客 提交于 2019-12-06 01:47:06
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 generate the document HTML NSArray *paths = NSSearchPathForDirectoriesInDomains

cocoa — getting nested NSViews and CALayers to resize proportionally

只愿长相守 提交于 2019-12-05 23:03:12
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. Here's what I've done to get the contents of an NSView to scale proportionally as I resize the parent window. First, in interface builder, I added my NSView to the window, then added a

keyUp event heard?: Overridden NSView method

核能气质少年 提交于 2019-12-05 22:47:18
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'm not sure if this is the right place to put it, though. I have a series of like buttons each set to a

How to block NSView events under another NSView?

感情迁移 提交于 2019-12-05 22:12:51
问题 Here is the idea: I have a NSWindow containing 2 NSView, let's call them ViewA and ViewB. ViewA has a list of subview objects, each object has its own tracking area set and handles a mouseDown event. ViewB is a hidden view, which appears above ViewA. The problem is when ViewB appears, ViewA still receives mouseDown events. So when I click on ViewB, the object behind the ViewB receives the mouseDown event. I would like to know if there's any way to block the events of ViewA while ViewB is over