Questions tagged [nsview]

NSView Implements basic drawing, event handling and printing behaviors for applications. Usually application code define subclasses of NSView to provide richer implementations. Belongs to the Foundation framework for Cocoa and Cocoa Touch.

The NSView class defines the basic drawing, event-handling, and printing architecture of an app. You typically do not use NSView objects directly. Instead, you use objects whose classes descend from NSView or you subclass NSView yourself and override its methods to implement the behavior you need. For any view object, there are many methods that you can use as-is.

1639 questions
12
votes
3 answers

How to set NSView size programmatically?

How do you set the size of NSView programmically e.g. -(void)awakeFromNib { self.frame.size.width = 1280; // Does nothing... self.frame.size.height = 800; // ...neither does this. ... The size setup in the nib…
Robin Pain
  • 639
  • 2
  • 8
  • 17
12
votes
2 answers

Swift: Switch between NSViewController inside Container View / NSView

I want to achieve a really simple task—changing the ViewController of a Container View by pressing a button: In my example the ViewController1 is embedded into the Container View using Interface Builder. By pressing the Button ViewController2 I…
ixany
  • 5,433
  • 9
  • 41
  • 65
12
votes
2 answers

NSWindow resize indicator not visible

How do I show resize indicators for an NSWindow without Titlebar? I created a new Xcode project(for Mac app) with storyboard. I just disabled the checkbox Title Bar in Appearance(It hides the Title bar of NSwindow). The strange thing was, after…
Kaunteya
  • 3,107
  • 1
  • 35
  • 66
12
votes
6 answers

Move a NSWindow by dragging a NSView

I have a NSWindow, on which i apply this: window.styleMask = window.styleMask | NSFullSizeContentViewWindowMask window.titleVisibility = NSWindowTitleVisibility.Hidden; window.titlebarAppearsTransparent = true; I then add a NSView behind the…
Leonard Schütz
  • 517
  • 1
  • 7
  • 16
12
votes
5 answers

How to use Swift playground to display NSView with some drawing?

Basically I would like to test a chart drawing in a Swift playground in NSView.
Alfa07
  • 3,314
  • 3
  • 26
  • 39
12
votes
1 answer

NSView equivalent of UIView Clip Subviews?

Is there a way to disable clipping of subviews of NSView? In UIView there is a “clip subviews checkbox” and the backing clipToBounds property, but I cant find anything similar in Cocoa. Here is my scenario: I have this grey dot that you can drag…
user961889
  • 351
  • 2
  • 12
11
votes
5 answers

How to block NSView events under another NSView?

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…
QyoDeveloper
  • 203
  • 2
  • 6
11
votes
5 answers

Show NSPopover from NSToolbarItem Button

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…
Stuart Tevendale
  • 614
  • 6
  • 19
11
votes
3 answers

Adding border and Rounded Rect in the NSView

In my Application , NSView should have rounded rect and border, i tried following static CGColorRef CGColorCreateFromNSColor (CGColorSpaceRef colorSpace, NSColor *color) { NSColor *deviceColor =…
Amitg2k12
  • 3,765
  • 10
  • 48
  • 97
11
votes
2 answers

NSView Subviews interrupting drag operation

I have an NSView which is registered for a drag operation. In that view I have a subclassed NSScrollView, which in itself has an NSImageView in it. When dragging onto the original NSView, everything is fine, other than when I drag over the…
mootymoots
  • 4,545
  • 9
  • 46
  • 74
11
votes
2 answers

Setting NSScrollView Contents to Top Left Instead of Bottom Left When Document Swapping

I had one of my colleagues come to me today with a problem of how can he load or view-swap a documentView of an NSScrollView so that the loaded view appears to fix to the top-left corner instead of the bottom-let corner. He had spent a while…
Hooligancat
  • 3,588
  • 1
  • 37
  • 55
11
votes
2 answers

Show Window without activating (keep application below it active)

I need to show a window (without title bar) above third party applications without my window taking focus. I have tried using an NSPanel and setting enabling non-activating, but that didn't help. I tried orderFront:self, but that didn't help…
user429620
11
votes
2 answers

Hover Over effect in NSCollectionView

I have an NSCollectionView with a few NSViews in it. The NSView has an NSBox in it that changes color when it is selected. I want to also make the NSBox change color when hovered over. I subclassed NSBox and added the mouseEntered and mouseExited…
marcopolo
  • 1,963
  • 4
  • 18
  • 31
10
votes
1 answer

Can't get AVPlayerLayer to display video in NSView

I am trying to make a simple HLS player to control playback and display on a secondary monitor. I am using AVFoundation on in 10.7 to control the playback. I can successfully create the AVPlayerItem and the AVPlayer, but I am having problems…
kcharwood
  • 2,501
  • 19
  • 22
10
votes
4 answers

What's the preferred/recommended way to draw a line in NSView-drawRect: method?

I couldn't found any line drawing primitive in Cocoa at NSView level. The only thing I've been found is NSBezierPath. Is this a preferred way? Or is there another way which I couldn't discovered?
eonil
  • 83,476
  • 81
  • 317
  • 516