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.

nsview
Filter by
Sorted by
Tagged with
1 vote
1 answer
85 views

NSView's frame is 0.5 pixels off from where the constraints suggest it should be

Has anyone seen something like this before? (lldb) po self.constraintsAffectingLayout(for: .horizontal) ▿ 5 elements - 0 : <NSLayoutConstraint:0x60000243f2f0 H:|-(NSSpace(20))-[MyApp....
Charles Srstka's user avatar
0 votes
1 answer
64 views

Access a IBOutlet id defined in one class in another

Hello I have an IBOutlet id which is used for a view it's defined in a class, I need to access it from another class how can I do this? I'm still learning ObjC so I appreciate your patience with me as ...
GeraldTheGerm's user avatar
-2 votes
1 answer
79 views

Tag for subclass of NSView returning -1

I have a class that is a subclass of NSView. When an instance of this view is clicked, it runs notificationCenter.post(name: .tileClicked, object: tag). However, the tag is always -1. How do I ensure ...
Ben A.'s user avatar
  • 1,138
1 vote
0 answers
162 views

How to rotate a view using angle and bounds size of a rotated layer in macOS using Swift?

I have CALayer that I rotate using Pan Gesture and CGAffineTransform. Here is how the CALayer rotates: containerView.layer?.addSublayer(caLayer!) /// Apply rotation let angleInRadians : CGFloat = ...
M Afham's user avatar
  • 882
-1 votes
2 answers
186 views

How can I CGWarpMouseCursorPosition() to the center of an NSView?

I am trying to create a game where the mouse is locked at the center of the screen. To complete this task, I found the appropriate method: CGWarpMouseCursorPosition Then I searched for how to get the ...
CPlus's user avatar
  • 4,154
1 vote
0 answers
92 views

Applying appropriate colors when switching appearance on macOS

I am trying to use semantic colors that are created like this: And I have a custom class called ColoredView, that looks like this: @IBDesignable class ColoredView: NSView { @IBInspectable var ...
Whirlwind's user avatar
  • 14.3k
0 votes
0 answers
101 views

"Bottom NSView's" button border line still appears in the "top NSView" after top View is presented

I'm working on a "Mac OSX App" that has two view controllers, the app starts from the first view (bottom view) and later "Canvas view controller (top view)" is presented from the ...
s4mt6's user avatar
  • 143
0 votes
1 answer
66 views

Subclassed NSView to notify ViewController of action

I have subclassed NSView to receive a dropped folder in order to get its URL. I've been getting the URL to my ViewController class by accessing a property set in my custom NSView class. import Cocoa ...
psb's user avatar
  • 131
0 votes
0 answers
423 views

Covert NSView's mouse down coordinates to screen coordinate system in cocoa Swift

override func mouseDown(with event: NSEvent) { let startPoint = event.locationInWindow print(startPoint) //for top left it prints (0, 900) To my knowledge the screen's origin is ...
unknown's user avatar
  • 898
0 votes
0 answers
50 views

How can I stop access to all NSView in a window after showing a new NSView on the whole window?

Let's say I have n number of views in a window but I want to restrict access to all of them and show a signInView above that and till the signIn is completed it should not let access to any other view ...
Kunj's user avatar
  • 11
0 votes
1 answer
63 views

NSTextField created from custom class appears randomly

I have a main NSView with 2 NSView subviews containing each a custom NSButton (all created in Interface Builder). My custom button class is programmatically creating an NSTextField below the buttons, ...
Laurent Crivello's user avatar
5 votes
0 answers
157 views

Swift: How can I turn a NSView 45 degrees? [closed]

I want to show my object, after drawing inner components, rolled to an angle of 45 degrees. How can I achieve this easily? The object is drawn with a sub-class of a NSView. It incorporates multiple ...
Yuma Technical Inc.'s user avatar
2 votes
0 answers
203 views

NSView draw() being called twice

I'm new to swift and Cocoa dev my problem is:- NSView's draw() function is being called twice. the results and code are below :- results [3/3] Linking MyCanvasApp Hello, World You got nothing. You got ...
Shashwat S's user avatar
0 votes
0 answers
90 views

MacOS Storyboards - structure with image and dozens of buttons underneath

As the header says, I am attempting to have a View that will allow an Image button on top as an entire row, and then a row of dozens of buttons underneath. There are all these nice sounding views (...
Cheetaiean's user avatar
0 votes
0 answers
405 views

Best way to redraw NSView 60 times per second?

I have a view in my OS X app that I need to fully redraw (ideally) 60 times per second. I'm currently using Core Graphics in the NSView draw function for the drawing like so: override func draw(_ ...
arghhh's user avatar
  • 15
0 votes
1 answer
247 views

Why does custom NSView redraw when window is resized or moved (drag) to an secondary display (monitor)?

I recently started adding graphic charts to a MacOS application I wrote. The first chart is great and I added a second chart where I ran into a fundamental way the code operates that I did not/do not ...
Mooky's user avatar
  • 23
0 votes
1 answer
37 views

NSViews insist on printing - how to disable this?

I have a single-windowed LSUIElement application ("status menu" app, lacking a menu bar) on App Store. I wanted my app to print, so I added a printing capability in XCode. Printing is done ...
user3494959's user avatar
1 vote
1 answer
417 views

How to add a table to a NS/UITextView in Swift?

I can see in Apple Notes and other notes app that they have tables embedded into the text editor. Swift has NSTextTable, but it's just available for macOS. I'm wondering how I can add a table to both, ...
Eduard's user avatar
  • 176
0 votes
0 answers
130 views

Problem to save to pdf file a NSView with rotated NSImageView as subview - NSImageView is not rotated

I have NSView and I am adding programatically a NSImageView (or NSTextField) as a subview. Then I do rotation of this subview by setting the angle for frameCenterRotation. The image of NSImageView is ...
VYT's user avatar
  • 1,071
0 votes
1 answer
212 views

NSView Animation not animating

I'm trying to animate an NSView by changing the value of its leading constraint. This is my constraint object: @IBOutlet weak var vModDatesLeading: NSLayoutConstraint! and the code I am using to ...
PruitIgoe's user avatar
  • 6,266
1 vote
2 answers
488 views

Swift 5 - Mac OS - NSTrackingArea overlapping views

Currently I have a little issue when it comes to buttons(NSButton) which have a tracking area and views(NSView overlay) above these buttons, this is my setup: Custom button: class AppButton: NSButton {...
Creative crypter's user avatar
0 votes
0 answers
120 views

Updating an NSView with processing in a separate thread

Suppose you have a scrollable NSView. When you scroll it, the part coming into the clipping rectangle will need to be refreshed, and the view's drawRect (Swift draw) method will be called for a ...
Zzyzx's user avatar
  • 43
0 votes
0 answers
386 views

How to resize NSView by dragging its edges?

Does anyone have an idea on how to systematically resize an NSView by dragging its edges? I would appreciate a working example and an explanation of the logic. Thank you in advance. I saw an example ...
Matthew1998's user avatar
0 votes
1 answer
210 views

How to position an NSView below another NSView?

Good day, Who has an idea on how to position an NSButton below another view in its superview? Here is the code I've written but the position of the NSButton doesn't change regardless of where the ...
Matthew1998's user avatar
0 votes
2 answers
298 views

SetNeedsDisplay on NSView triggers the redrawing of the whole views hierarchy

I'm working on an app made by a NSWindow which own a lot of custom subviews, that could be opaque or not. Whenever I call SetNeedsDisplay: or SetNeedsDisplayInRect: on a subview, the system calls the ...
andrea's user avatar
  • 61
0 votes
1 answer
161 views

How to add radio button property to Custom View using NSButton and NSTextfield

I m creating a custom NSView, it has NSBUTTON of type radio and NSTextfield. Right now, it doesnot show property of radio button i.e. if I select one radio button, other radio buttons should go off. ...
Rohit Sharma's user avatar
0 votes
1 answer
112 views

NSBezierPath stroke not scaled correctly

I have what should be a simple subclass of an NSView that draws circular nodes at specified locations. To render the nodes in my view, I translate the graphics context's origin to the center of the ...
MikeMayer67's user avatar
3 votes
3 answers
4k views

Observe window resize event with SwiftUI

I currently have a LazyVGrid setup as such: struct NetworkGrid: View { var networks: [Network] let columns = [ GridItem(.flexible()), GridItem(.flexible()), ...
JDev's user avatar
  • 5,408
0 votes
0 answers
155 views

Receive trigger when active NSView focus changes

I'm surprised that I haven't been able to find an answer for this from searching. So if there is a page describing how to do this, let me know, but I've been unable to find it. I have 3 sibling ...
silicontrip's user avatar
1 vote
1 answer
252 views

View in NSMenu not clickable if window is invisible

I experience a really strange behaviour with an NSMenu in an "Application is agent"-Application. I have the following simple code to setup a titlebar icon with an NSMenu. The menu contains a ...
user688262's user avatar
0 votes
1 answer
322 views

Using a view with a superlayer as a layer mask

I have a view that I want to overlay with a transparent black layer whose edges match the view exactly. The view does not clip its bounds, so subviews may be hanging off. The obvious solution is the ...
aleclarson's user avatar
  • 18.5k
0 votes
0 answers
90 views

Add onlick event to NSView programatically without subclassing

I create a bunch of NSviews programmatically. How can I set the function that is performend when the NSView is clicked? For NSButton you can use button.addTarget. For NSView this doesn't exist however....
user688262's user avatar
0 votes
1 answer
376 views

Content of NSScrollView sticks at bottom when resizing

When I add a custom NSView to my NSScrollView via documentView and resize the window the content sticks always to the bottom of the window (so the scroll view is always scrollt to the bottom when the ...
Mike Nathas's user avatar
  • 1,333
1 vote
1 answer
90 views

No scrollbars appear when adding a custom view via addSubview to NSScrollView

I dynamically want to add a custom NSView as a content of a NSScrollView via code in runtime. So I added a NSScrollView to my NSWindow, created an outlet to this NSScrollView and add my custom view. @...
Mike Nathas's user avatar
  • 1,333
1 vote
0 answers
312 views

Tooltips showing from underneath an NSView/NSBox

I'm running into an issue in a mac osx app. I'm displaying a popover using an NSBox and I'm noticing tooltips from elements underneath are showing through I've created a quick demo project to show ...
GP89's user avatar
  • 6,680
0 votes
1 answer
119 views

rightMouseDown not called until button released

I have an NSView subclass in which I need to detect left and right mouse down events. mouseDown: is working just fine, but rightMouseDown: doesn't fire until the mouse button has been released, at ...
bjørnfelle's user avatar
0 votes
1 answer
425 views

NSStackView, fill view when one of the subviews is hidden

I have a vertical NSStackView that has this behavior. It has two subviews, one of them at top of the stack view, that will have a fixed height. Then, there is another view that will cover the ...
Jacobo's user avatar
  • 1,361
4 votes
1 answer
2k views

Is there a way to load swiftUI view into NSView?

I would like to know if it's possible to load a SwiftUI view into an NSView. I was hoping to set the windows content view to aSwiftUI but it seems impossible window?.contentView = view where view is ...
Tochukwu's user avatar
  • 300
0 votes
0 answers
42 views

How to foward NSView keyboard handlers to the main window?

I have a custom NSView implementing keyDown and keyUp methods, but it's actually a plugin and it is desirable to somehow send the keys to the host if the key strokes hasn't been used. Is there a way ...
mrzacek mrzacek's user avatar
0 votes
0 answers
38 views

NSPrintOperation creates a blank page [duplicate]

I am not able to print in Cocoa using the service: [[NSPrintOperation printOperationWithView:self] runOperation]; The print dialog gets launched but the preview is blank. Please let me know what could ...
amit kulkarni's user avatar
9 votes
4 answers
2k views

How do I update a CALayer with a CVPixelBuffer/IOSurface?

I have an IOSurface-backed CVPixelBuffer that is getting updated from an outside source at 30fps. I want to render a preview of the image data in an NSView -- what's the best way for me to do that? I ...
andrew's user avatar
  • 1,213
0 votes
1 answer
346 views

Animate NSView constraints (layer backed view) on macOS objective-c

I am on XCode 12, macOS, objective-c, not iOS. I have a menu (horizontal stack view) with 3 items: The blue underline is created programmatically: - (void)viewDidLoad { [super viewDidLoad]; ...
Pat_Morita's user avatar
  • 3,415
2 votes
0 answers
594 views

How to detect mouse event outside current NSView in MacOS?

Dues to I am using CALayer's mask attribute to draw and clip the content, the mask's size is like a NSView with a 10 pixel border, some of my content is larger than the current NSView's size with 10 ...
彭煥閎's user avatar
  • 107
1 vote
0 answers
60 views

c# on mac OSX 10.15.6 UpdateLayer() stroke line not display in NScustomview

I am new on MAC programming specific to OSX in C#; I would like to be able to refresh a customview to draw dynamically lines (i.e. stock charts) using an array from ViewController.cs on a mousedown ...
Wizard46's user avatar
1 vote
0 answers
109 views

(NSTextView).visibleRect with SwiftUI doesn't work as expected

I'm trying to make a Discord-like text field. So I used a custom text field from here and modified a bit. (Changed not to draw background) But it doesn't expend as I expected. And I found that (...
Helloyunho's user avatar
0 votes
0 answers
271 views

How can I accept Directories in a Drag and Drop zone?

Hello I've implemented multiple drag and drop areas in my app and by now everything worked fine because I only had to drop files of various types. Now I have a NSView where I need to drop only folders....
Shoni Fari's user avatar
0 votes
2 answers
166 views

How store a tuple for NSGradient(colorsAndLocations:) in swift

To apply a gradient to a NSView, it seems best to make a class that inherits from NSView and override the draw method that sets a path and draws the gradient. class GradientView: NSView { var ...
Yuma Technical Inc.'s user avatar
0 votes
2 answers
373 views

custom NSView with video player is not showing (MacOS)

I have created a custom NSView with an AVPlayer embedded and it is not showing at all this is my header: @interface VideoPlayer : NSView - (void)loadVideo; @end Implementation: @implementation ...
Diego Gomez's user avatar
0 votes
0 answers
154 views

Scroll bars not displaying for NSView placed inside a NSScrollView in MacOS application using XCode

I am running with an issue where the Label text which is placed inside NSView is getting cut off at bottom and right side of content view & even scroll bars are not getting displayed. I am using ...
Kamal's user avatar
  • 503
-1 votes
1 answer
764 views

Add horizontal and vertical scroll bars to NSView for MacOS app using XCode Objective-C

I am new to macOS standalone application development and I am working on fixing the issue in our existing application. I am running with an issue where the controls inside NSView are getting cut off ...
Kamal's user avatar
  • 503

1
2
3 4 5
33