nsview

NSView makeBackingLayer with CALayer subclass displays no output

99封情书 提交于 2019-12-13 03:29:50
问题 This is a continuation of my question stop-nsview-drawrect-clearing-before-drawing-lockfocus-no-longer-working-on-mojave. I used the pattern lockFocus-graphics context-flushWindow pattern to draw into another view. That no longer works on macOS 10.14, as the backing store of views has changed (for new binaries). NSView has a method makeBackingLayer that is not there for nothing, I guess. The code snippet below has makeBackingLayer called, and I can have it use my CALayer subclass

Changes not reflected across view when using binding in cocoa

ぐ巨炮叔叔 提交于 2019-12-13 02:23:27
问题 I am creating some sample applications to understand the concepts of view navigation, binding etc in cocoa. Here is the scenario: I have a window that has a tab view(2 tabs) in MainMenu.Xib. I have a text field in the first tab and label in the second tab. I want both of them to reflect the same value and I want to do this using binding. Also, I don't want to use the views provided to me along with the tab view. These are the steps I have done. The view of each tab view item is set separately

In Cocoa, what is the best way to change the cursor when hovering over a circular view?

我是研究僧i 提交于 2019-12-12 14:59:04
问题 What I want to do I have a circular custom NSView subclass, and I want to change the appearance of the cursor when the mouse is hovering over the circular portions of the view, but not when over the portions of the view's rectangle that fall outside the circle. Here's an illustration. I would have inlined it with an image tag, but I'm too new to partake of such awesome features. What I know so far I know how to change the appearance of the cursor through NSCursor. I think that the best way to

NSButton on NSVisualEffectView: Wrong Background Color

最后都变了- 提交于 2019-12-12 07:37:32
问题 I have a NSVisualEffectView within a NSPopover developed for 10.10 . When subclassing the NSVisualEffectView to have hover background color effect, the borderless button color seems to be different I tried setting the backgroundColor of the button cell to clearColor or the same as I used in drawRect: in of the NSVisualEffectView , the former gives wrong color (not filled with blue) and the later still the same with wrong color. (gray box around its border). CALayer can fix this but is there a

Drop location in NSView

[亡魂溺海] 提交于 2019-12-12 03:59:56
问题 I'm writing a Cocoa Application (XCode 7.0.1) and within it, I have a NSTableView and a NSView. The application is designed in a why that we can drag and drop items from the NSTableView into the NSView. The drag and drop works properly, but I can only register that something is dropped on the NSView and not where in the NSView. I was wondering if there is a way to get the location of the drop within the frame of NSView? I have tried all mouse events that NSView can have but they don't seem to

Can't see a new subview

杀马特。学长 韩版系。学妹 提交于 2019-12-12 02:18:24
问题 All I am trying to do is add a new view to the content view of my NSWindow instance. When I do the following I do not see the new view (which should be black and take up the entire window). What am I doing wrong? (done in response to a button click) NSRect frameRect = [self.window frame]; frameRect.origin = NSZeroPoint; NSView *view = [[NSView alloc] initWithFrame:frameRect]; view.wantsLayer = YES; view.layer.backgroundColor = [NSColor blackColor].CGColor; [self.window.contentView addSubview

Loading NSView subclass from a XIB

一世执手 提交于 2019-12-12 01:46:07
问题 I need to use a custom view into a NSMenuItem. I've created a new view XIB and customized the view in it. How can I load that view and set it in the NSMenuItem using the setView: method? UPDATE : I've found a solution but now the menu item with the custom view doesn't highlight on mouse over. Ho can I solve this problem? 回答1: I've created a NSViewController subclass and set it as the file's owner in the XIB. Then I've set the view outlet of the file's owner to the view in the XIB and finally

NSView subView not visible after added to superView

£可爱£侵袭症+ 提交于 2019-12-12 01:28:08
问题 this is my final window i added 4 subviews (last 4 in 2nd image) to the base view. but not displaying the view. after manual resizing window the subviews appeared as below. how can fix it? 回答1: baseView.needsDisplay = YES; -- or -- subview.superview.needsDisplay = YES; 回答2: You can use NSScrollView: NSScrollView* scrollView = [[NSScrollView alloc] init]; [scrollView setHasHorizontalScroller: YES]; [scrollView setHasVerticalScroller: YES]; self.contentView = [[NSView alloc] initWithFrame:

Why does Xamarin.Mac window abruptly disappear?

限于喜欢 提交于 2019-12-12 01:06:23
问题 I recently posted about a bug in MonoMac in which the window would abruptly disappear after clicking on a button 20 times or so. That bug, it turned out, doesn't seem to affect Xamarin.Mac, so I switched my project to that. But now I'm seeing virtually the same bug in a different context: after typing a few lines of text into an NSTextField, the window disappears in exactly the same manner. No error, no exception; it just vanishes. Poof, gone! I've reproduced this in a trivial project: you

How to change the focus ring color?

眉间皱痕 提交于 2019-12-11 13:42:17
问题 In the draw function of the NSImageView ,I want to set my custom focus ring color,not the default blue color.I tried as follows code NSSetFocusRingStyle(NSFocusRingOnly); [[NSColor redColor] setStroke]; NSRectFill([self bounds]); But the color is still default blue color.How can I solve this problem? update: The NSShadow class help me to accomplish adding focus ring.It's easy to change the shadow color. NSShadow *shadow = [[[NSShadow alloc] init] autorelease]; [shadow setShadowBlurRadius:5];