nsview

NSColorWell subclass not getting mouseMoved events

I'm trying to implement a color picker in my Cocoa app. (Yes, I know about NSColorPanel. I don't like it very much. The point of rolling my own is that I think I can do better.) Here's a picture of the current state of my picker. The wells surrounding the color wheel are NSColorWell subclasses. They are instantiated programmatically ...

How do I fix the height of my view after collapsing NSSplitView?

I've got an NSSplitView with an NSScrollView in the bottom view. The problem is when I collapse, and then re-open (un-collapse) the bottom view, the height of the scroll view is beyond the height of that bottom view so the top part of the scoll view is being clipped. I've got my scroll view and my split view set to autoresize in all di...

Drawing an image in a NSView

I have a simple Obj C program that, at the moment, lets you load an image, draws it up, and theoretically should let you zoom and rotate. I'm using NSAffineTranslations. I want the image to be locked to the upper left (As opposed to the PS/PDF standard of lower left), so I'm using isFlipped, and calling [afTrans scaleXBy:1.0 yBy:-1.0]; ...

How do I make an NSView move to the front of all NSViews

Hi! How do I make an NSView window move up to the front. My app has 3 windows and when I press a button in one of them I want another to move on top of this one. ...

NSView leaves artifacts on another NSView when the first is moved across the second

I have an NSView subclass that can be dragged around in its superview. I move the views by calling NSView's setFrameOrigin and setFrameRotation methods in my mouseDragged event handler. The views are both moved and rotated with each call. I have multiple instances of these views contained by a single superview. The problem I'm having is...

How to Rotate a CALayer-backed NSView subclass

I have a custom NSView subclass that I want to animate with Core Animation. I am already (without CA) setting the position and rotation of these views with NSView's setFrameOrigin and setFrameRotation methods. However, no matter what I do, once I add a layer backing to the views I can't get them to rotate. I've tried using NSView's setF...

NSMatrix and autoresize only certain cells?

I have an NSMatrix with two columns, When the frame resizes I don't want the left column to resize with it. Is there a way to do this without subclassing NSMatrix? I am thinking maybe I should just make two NSMatrix's and position them side-by-side, one with autoresizing set to YES and one set to NO. Is this the most appropriate way ...

drawRect not being called on added subview

I'm trying to programmatically create a window with custom contentView and one custom NSTextField control, but i'm having trouble getting this hierarchy of window and views to draw themselves. I create a custom borderless window and override it's setContentView / contentView accessors. This seems to work fine and custom contentView's in...

Dimming NSWindow and layer NSView on top

Is there any way I could dim my NSWindow (basically putting a black transparent layer over top of it that you cannot click through) and then layer a custom NSView on top? ...

mouse click events in an NSView subclass

Hello, I have an NSView subclass that gets initialized with an OpenGL context and has a bunch of mouse event handling (onMouseDown, etc...). I have an app using it which has a main Cocoa window that contains the view and all the mouse events are working properly. However, I'm trying to use it now in another app where i have a secondary...

Menu Items, Responder Chains, and NSViewController, Oh My!

I must be missing something simple, but I can't see it. First, the setup: DATreeView, a subclass of NSView DATreeViewController, a subclass of NSViewController MainMenu.xib has an instance of DATreeViewController, which is configured to load a view from DATreeView.xib MainMenu.xib also has an instance of DendreaAppDelegate, which has ...

Making NSScroller larger

I'm making a Cocoa application optimized for external touch sensitive screens, so I want to make a large scollbar in an NSScrollView. I've tried just to resize the scrollers frame, but both drawing and mouse events only happens in the scroll area, it doesn't get wider (it's the vertical scroller). This is the code I'm using (from the sub...

Why is bitmapImageRepForCachingDisplayInRect: creating an empty image?

I have a very simple bit of code that is supposed to capture the bitmap of a view. This used to work in Leopard, but seems horribly broken in Snow Leopard. Here is the code, responding to a button press on the window: - (IBAction)snapshot:(id)sender { NSView* view = [[sender window] contentView]; NSBitmapImageRep* bitmap = [view b...

Resize view of NSCollectionViewItem

How do I programatically set the size of a view of an NSCollectionViewItem? I tried doing this in an NSCollectionView subclass: @implementation CustomCollectionView - (NSCollectionViewItem *)newItemForRepresentedObject:(id)object { NSCollectionViewItem *newitem = [[self itemPrototype] copy]; [newitem setRepresentedObject:obje...

Graying out an NSWindow's content

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

Distinguishing a single click from a double click in Cocoa on the Mac

I have a custom NSView (it's one of many and they all live inside an NSCollectionView. I don't think that's relevant, but who knows?). When I single-click the view, I want it to change its selection state (and redraw itself accordingly); when I double-click the view, I want it to pop up a larger preview window for the object that was jus...

Custom NSStatusItem with custom view - Use NSWindow, NSView, custom NSMenuItem?

I'm trying to create a LSUIElement app that behaves like Spotlight, CoverSutra and other apps of that type. I managed to create a custom NSStatusItem, which popups up an NSWindow but the problem is that the app that currently has focus will the focus to my custom NSWindow. I've based myself on Matt Gemmell's example (http://mattgemmell....

Center an NSView within an NSScrollView

How do I center an NSView within an NSScrollView like the way "Preview" does? ...

Drawing in NStextField

Hey ho! If you wanted to implement a highlighting for specific substrings in a NSTextField like on the screenshot (Tweetie.app) how would you do it? :) Thanks for your help! ...

After loading nib with NSViewController... how do I access the NSButton in the nib?

I've subclassed NSViewController with IBOutlets hooked into an NSButton in a secondary nib. I can instantiate the NSViewController and apply the view in an NSMenu -- it works great -- but how do I access the button to change its title? Since the NSViewController has IBOutlets, I assumed I'd do this through the controller. //this part ...