nsview

How to tell what's causing drawRect to be called?

萝らか妹 提交于 2019-12-11 10:33:26
问题 I've got my custom NSView with a bunch of custom buttons in it, the buttons are added as a subView in the NSView's drawRect method. Now I'm finding that after pressing a button the drawRect of the parent view is repeatedly called. Sometimes it only stops when I quit the app - I know this from a simple log statement in drawRect. Now I know there are probably bigger architectural issues in my app causing this, where do I go to begin tracking down what's causing this view to be repeatedly

NSView* from wxPython

对着背影说爱祢 提交于 2019-12-11 04:57:34
问题 I'm developing a Python module that needs to get a pointer to a NSView in order to attach OpenGL to a window. I'm using wxPython as GUI library that has a method GetHandle() that, as the documentation says, 'Returns the platform-specific handle (as a long integer) of the physical window'. Because my module has to be compatible with both Windows and Mac, I've made a wrapper function that takes a unsigned long and cast it to a void* in order to pass it to the actual method that handles the

How can I show an image in a NSView using an CGImageRef image

前提是你 提交于 2019-12-11 04:16:51
问题 I want to show an image in NSview or in the NSImageView. In my header file I have @interface FVView : NSView { NSImageView *imageView; } @end here is what I been trying to do in my implementation file: - (void)drawRect:(NSRect)dirtyRect { [super drawRect:dirtyRect]; (Here I get an image called fitsImage........ then I do) //Here I make the image CGImageRef cgImage = CGImageRetain([fitsImage CGImageScaledToSize:maxSize]); NSImage *imageR = [self imageFromCGImageRef:cgImage]; [imageR lockFocus]

Grey border around view when using NSBorderlessWindowMask

有些话、适合烂在心里 提交于 2019-12-11 02:43:37
问题 I'm having the exact same problem as in this question: Gray border when using NSBorderlessWindowMask However, the accepted answer (as in the comments) of removing the window shadow doesn't seem to work, at least on Lion. I've subclassed NSWindow , and created a borderless window in this manner: -(id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag { self = [super initWithContentRect:contentRect styleMask:

How to flash a custom NSMenuItem view after selection?

放肆的年华 提交于 2019-12-11 02:43:25
问题 I need to assign a view to an NSMenuItem and do some custom drawing. Basically, I'm adding a little delete button next to the currently selected menu item, among other things. But I want my custom menu item to look and behave like a regular menu item in all other ways. According to the doc: A menu item with a view does not draw its title, state, font, or other standard drawing attributes, and assigns drawing responsibility entirely to the view. Ok, so I had to duplicate the look of the state

Cocoa: Crash in _NSDisplayOperationStack; Need Guidance

夙愿已清 提交于 2019-12-10 23:23:08
问题 The Problem I'm receiving crash reports from users that look like this: Code Type: X86-64 (Native) Parent Process: launchd [223] Date/Time: 2012-03-22 11:28:33.087 +0800 OS Version: Mac OS X 10.7.3 (11D50) Report Version: 9 Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: 0x000000000000000d, 0x0000000000000000 VM Regions Near 0: --> __TEXT 000000010c202000-000000010c29c000 [ 616K] r-x/rwx SM=COW /Applications/CodeKit.app

Adding objects to an NSView

心不动则不痛 提交于 2019-12-10 22:39:15
问题 I have an NSView inside my project's window as seen in the picture below: How do I add NSImageViews to the subview of this 'Custom View' so its displayed in there rather than directly in the main window of the application? 回答1: Programmatically, you would access the view to which you want to add subviews, then call the -addSubView: method on it. You can access it either as an IBOutlet hooked in to interface builder, or access it by Identifier (set the Identifier string in the "identity"

How to prevent a NSCursor from change?

我的未来我决定 提交于 2019-12-10 16:56:50
问题 I have a problem while I try to prevent a cursor from changing. I try to put an overlay View over entire window, but, if under that overlay exist an NSTextView, this will force cursor to change. I want to prevent that, and keep the arrow cursor until my overlay view will be removed. Overriding the cursorUpdate method does not work... override func cursorUpdate(with event: NSEvent) { return } Thanks! Even this (question 32447739) answer does not help. This solution is valid only if the overlay

MTKTextureLoader saturates image

心不动则不痛 提交于 2019-12-10 15:29:42
问题 I am trying to use a MTKTextureLoader to load a CGImage as a texture. Here is the original image However after I convert that CGImage into a MTLTexture and that texture back to a CGImage it looks horrible, like this: Here is sorta what is going on in code. The image is loaded in as a CGImage (I have checked and that image does appear to have the full visual quality) I have a function view() that allows me to view a NSImage by using it in a CALayer like so: func view() { ..... imageView!.layer

How to change the mouse style of NSView and NSButton on NSTextView

主宰稳场 提交于 2019-12-10 15:15:21
问题 There is a NSView on top of NSTextView, and the range of NSTextview is larger than the NSView range. NSView has some of the above NSButton and so on, work very well, but the mouse style makes me a bit puzzled. I think that when the mouse moves to NSView, it has been a arrow style, but not, it always displays the iBeam style. Because it's on the NSTextView, so when my mouse moves to NSView, it shows the iBeam style. I change mouse NSCursor.arrow.set in real time by override func mouseMoved