nsview

Why "add subview" not work?

Hello, I try add subview but not work. My code is: HomeViewController* homeViewController = [[HomeViewController alloc] initWithNibName:@"HomeView" bundle:nil]; NSViewController *viewController = homeViewController; [mainView addSubview: [viewController view]]; NSLog(@"%@",[viewController view]); NSLog(@"%@",[[viewController view]superv...

Rotating NSView that holds an NSImageView

Hi All, I am creating an NSView, which in its drawRect method creates and adds an NSImageView as a subview. I would like to rotate this NSImageView (circleView), or [self]. So in another method, I am trying to do that: -(void)startAnimation { CABasicAnimation* spinAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation...

Reusable bits of interface, designed in IB

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 chang...

Draw an NSView into an NSGraphicsContext?

I have a CGContext, which I can turn into an NSGraphicsContext. I have an NSWindow with a clipRect for the context. I want to put a scrollview into the context and then some other view into the scrollview so I can put an image into it... However, I can't figure out how to attach the scrollview into the context. Eventually the view will...

NSSlider and Movable by Background Window

Hi, I have an NSSlider inside a view. That view is a subview of a view in my window. The window is movable by background and if I want to change the value of the NSSlider by dragging it around then my whole window will move. If I make my window unmovable by background then it works or if I put the NSSlider in the first view (not the sub...

entering fullscreen on subclassed NSOpenGLView leaves empty window

hello, i have an application with 2 windows, one is a custom subclassed NSOpenGLView and one is displaying some standard cocoa user interace. making the opengl view go fullscreen (only on one NSScreen) works by calling enterFullScreenMode and exitFullScreenModeWithOptions and supplying the right screen and setting NSFullScreenModeAllS...

Custom NSView Fill Paints Over Bottom Bar

I have a window which has a custom NSView and has a bottom bar with controls on it, one of which is an NSColorWheel. For simplicity sake the Window is 332px high, with the custom NSView being 300px high and the bottom bar being 32px high. The bottom bar is created as part of my awakeFromNib when the app loads the window using the follo...

Resizing views in Interface Builder

I'm having trouble visualizing something. Let say I have three views inside a scrollview with some other content. Top, buttons and image. buttons and image are both inside top. Top does NOT fill up the scrollview, however, buttons and image DO fill up top. Top has a maximum size determined at runtime, but it might not all be visible. Th...

Is the method addSubview of NSView inherently slow? (Cocoa OSX)

I am trying to speed my gui that loads very slow slow when I am loading a large project (the gui is a representation of groups and sub groups and is made up of many views). During this process I was looking at how long certain code segments take to execute and I have found that a call to addsubview is taking between 10 and 20 millisecon...

Printing an invisible NSView

Initially I created a simple program with a custom NSView. I drew a picture (certificate) and printed it! beautiful! Everything worked great! I them moved my custom NSView to an existing application. My hope was that when a user hit print it would print this certificate. Simple enough. I figured a could have a NSView pointer in m...

Zooming in an NSView

Hi, I have an NSView in which the user can draw circles. These circles are stored as an array of NSBezierPaths, and in drawRect:, I loop through the array and call -stroke on each of the paths. How do I add a button to zoom in and out the NSView? Just change the bounds of the view? Thanks. ...

Embed font in a mac bundle

I have a program I am writing. I want to use a fancy font. Can I just embed my font into my bundle and use it from there. My code... NSMutableAttributedString *recOf; recOf = [[NSMutableAttributedString alloc] initWithString:@"In Recognition of"]; length = [recOf length]; [recOf addAttribute:NSFontAttributeName value:[NSFont fontWi...

Printing an NSDocument

I'm trying to print a document. The document is an array of NSImageReps, or a single NSPDFImageRep, which has multiple pages. I'm having trouble figuring out how to use the NSPrintOperation class to print this. The NSPrintOperation seems to need an NSView to print. Do I need to manually add each image into the view at a calculated pos...

NSTableView and NSSearchField in an NSView, which is the outlet of an NSMenuItem, don't work

I'm having an NSView, which is set as the view: outlet of an NSMenuItem. The view contains an NSTableView (inside an NSScrollView) and an NSSearchField. The NSMenu is shown when the user clicks a specific NSStatusItem. When I launch the application from Xcode (Build and Run), the controls behave well, but whenever I launch it from the Fi...

Subview of custom NSView is resizing itself to fit within its superview

I have a custom NSView which contains a subview—for the purposes of solving this issue, the top level view is simply acting as a container and automatically resizes to fit within the window. Its subview draws a rectangle 10 pixels inset from the edge of the window, except for the bottom, which should get clipped by the window until it's ...

NSTextView's adjustScroll method

I'm trying to implement typewriter scrolling in my Cocoa text editor, keeping the insertion point centered vertically in its scrollview. Toward this end, I have subclassed NSClipView to provide a scrollToPointWithoutConstraint method, which scrolls the document to a specified point without calling constrainScrollPoint. This is necessary...

Selection Highlight in NSCollectionView

On some occasions my head just hurts from banging it against the Cocoa wall. Today is one of those days. I have a working NSCollectionView with one minor, but critical, exception. Getting and highlighting the selected item within the collection. I've had all this working prior to Snow Leopard, but something appears to have changed and ...

How to imitate the workflow view of Automator?

I’m starting to develop my first full-blown Cocoa application containing a view which I would like to behave (and look) similar to Automator’s AMWorkflowView. The basic features I’d like to achieve: Positioning of subviews Display of subviews in expanded / collapsed states Multiple selection Drag and drop In order to get accustomed...

resetting the image in an NSView

I think this is a very simple question, but I’m new to programming so I may be going about it in a wrong-headed way. I have a basic understanding of Objective-C writing terminal applications and am teaching myself how to use the Cocoa GUI. I understand how to use IBOutlet and IBAction to connect a simple button to a method that wil...

Displaying an NSString on a Custom View

I have an interface that has an NSTextField, NSButton, and an NSView. When I type something in the textfield and press the button, I want the text to be drawn in the NSView. So far I have everything connected and working, except for the view. How can I connect the text and the view so that every time I press the button, the text is dra...