nsview

Resizing nspopover

老子叫甜甜 提交于 2019-12-23 02:45:57
问题 I am trying to resize an NSPopover prior to displaying it by setting the frame of the NSView it contains using the method: setFrameSize: However, when I try to display the popover by calling: showRelativeToRect: ofView: preferredEdge: The view returns to its previous size. Why is this happening? Is there another way I should be sizing the popover? Thanks in advance, Ben. 回答1: There's a setContentSize on the popover, but I have the impression this doesn't work so well. I mean it works, but

Reusable bits of interface, designed in IB

纵然是瞬间 提交于 2019-12-23 02:21:30
问题 I'm making an app that includes the same group of buttons in many different contexts. The buttons send their actions to a different object in each context. I'd like to be able to design a single NSView in IB containing the buttons, and then be able to put copies of that view in many places in my nibs, while maintaining the link, so changes propagate. I'd like to connect each of those instances to different objects, and have the buttons send their actions to whatever object their parent view

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

爱⌒轻易说出口 提交于 2019-12-22 09:53:16
问题 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. 回答1: Maybe you should try it this way: #define menuItem ([self enclosingMenuItem]) -

Binding a custom NSView: Does it demand creating an IBPlugin?

妖精的绣舞 提交于 2019-12-21 07:31:18
问题 I have created a subclass of NSView to draw an image as a pattern: @interface CePatternView : NSView { NSImage* image; id observableObjectForImage; NSString* keyPathForImage; } @end I implemented the following to expose bindings: + (void)initialize { // Expose the "image" binding to IB. [self exposeBinding:@"image"]; } - (Class)valueClassForBinding:(NSString *)binding { if([binding isEqualToString:@"image"]) return [NSImage class]; return nil; // Unknown binding } Unfortunately, the image

Rounded rect on NSView that clips all containing subviews

ε祈祈猫儿з 提交于 2019-12-20 17:41:12
问题 I am creating a NSView subclass that has rounded corners. This view is meant to be a container and other subviews will be added to it. I am trying to get the rounded corners of the NSView to clip all of the subview's corners as well, but am not able to get it. - (void)drawRect:(NSRect)dirtyRect { NSRect rect = [self bounds]; NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:self.radius yRadius:self.radius]; [path addClip]; [[NSColor redColor] set]; NSRectFill(dirtyRect

Rounded rect on NSView that clips all containing subviews

百般思念 提交于 2019-12-20 17:40:03
问题 I am creating a NSView subclass that has rounded corners. This view is meant to be a container and other subviews will be added to it. I am trying to get the rounded corners of the NSView to clip all of the subview's corners as well, but am not able to get it. - (void)drawRect:(NSRect)dirtyRect { NSRect rect = [self bounds]; NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:self.radius yRadius:self.radius]; [path addClip]; [[NSColor redColor] set]; NSRectFill(dirtyRect

NSImage from a 1D pixel array?

China☆狼群 提交于 2019-12-20 10:58:20
问题 I have a large 1D dynamic array in my program that represents a FITS image on disk i.e. it holds all the pixel values of the image. The type of the array is double . At the moment, I am only concerned with monochrome images. Since Cocoa does not support the FITS format directly, I am reading in the images using the CFITSIO library. This works - I can manipulate the array as I wish and save the result to disk using the library. However, I now want to display the image. I presume this is

any Cocoa control code that I can use that acts as a patch bay?

假装没事ソ 提交于 2019-12-20 10:57:12
问题 I would like to make a patch bay type control... any source online that anyone knows of that I could work from? Thanks 回答1: The closest thing I'm aware of is EFLaceView: http://www.cocoadev.com/index.pl?FlowChartView Edit: EFLaceView seems to have disappeared, but I have a saved copy: EFLaceView Edit: Version of EFLaceView on github, with more recent changes than link above. 回答2: Unless you can find someone online who is sharing exactly the kind of control you're looking for, you don't have

Stop NSView drawRect clearing before drawing? (lockFocus no longer working on macOS 10.14)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 03:52:38
问题 I have an animation using two views where I would call lockFocus and get at the graphics context of the second NSView with [[NSGraphicsContext currentContext] graphicsPort], and draw. That worked fine until macOS 10.14 (Mojave). Found a reference here: https://developer.apple.com/videos/play/wwdc2018/209/ At 22:40 they talk about the "legacy" backing store that has changed. The above lockFocus and context pattern was big on the screen, saying that that won't work any more. And that is true.

Why are subviews of an NSView not sent a release message when a Cocoa application terminates?

99封情书 提交于 2019-12-18 16:26:18
问题 The short version: Why are the subviews of NSView objects not sent a release message when a Cocoa application terminates? Is there a way to override this behaviour? An example: The MyView class shown below is nothing more than an NSView subclass that reports to the console when it is created and destroyed. I have tested it out and found it to work properly. However, when I use it as shown in the next code snippet from my application delegate, I see something unexpected (see sample output). //