nsview

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

♀尐吖头ヾ 提交于 2020-01-20 17:13:31
问题 I have a super view, which has 2 subviews. These subviews are overlapped. Whenever i choose a view from a menu, corresponding view should become the front view and handle actions. i.e., it should be the front most subview. acceptsFirstResponder resigns all work fine. But the mouse down events are sent to the topmost sub view which was set. Regards, Dhana 回答1: Here's another way to accomplish this that's a bit more clear and succinct: [viewToBeMadeForemost removeFromSuperview]; [self

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

蓝咒 提交于 2020-01-20 17:09:12
问题 I have a super view, which has 2 subviews. These subviews are overlapped. Whenever i choose a view from a menu, corresponding view should become the front view and handle actions. i.e., it should be the front most subview. acceptsFirstResponder resigns all work fine. But the mouse down events are sent to the topmost sub view which was set. Regards, Dhana 回答1: Here's another way to accomplish this that's a bit more clear and succinct: [viewToBeMadeForemost removeFromSuperview]; [self

Are layer-backed NSView siblings allowed to overlap?

放肆的年华 提交于 2020-01-19 07:58:40
问题 I'm a little confused. The Apple Documentation states this: Note: For performance reasons, Cocoa does not enforce clipping among sibling views or guarantee correct invalidation and drawing behavior when sibling views overlap. If you want a view to be drawn in front of another view, you should make the front view a subview (or descendant) of the rear view. So according to this, sibling views should not overlap or else the behavior is undefined. In the Cocoa Slides demo app, however, layer

Setting the background of a custom view with an image results in a black background

白昼怎懂夜的黑 提交于 2020-01-17 08:55:20
问题 I have a problem setting the background of my subclassed NSView called TitlebarView . I want to use an image as a background via colorWithPattternImage , but the result is a black background not the image i gave the method as a parameter. Here's my code of TitlebarView : - (id)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; if (self) { NSString* pathToTitlebarBGImage = [[NSBundle mainBundle] pathForResource:@"titlebar_bg" ofType:@"png" inDirectory:@"Resources/gui_images"];

create a subclass of NSView to enable setTag()

蹲街弑〆低调 提交于 2020-01-17 06:09:41
问题 I am using xamarin to develop a Mac app, and somewhere in my program I want to set the tag of a NSView. However, the tag property is readonly for NSView, so I'm searching for a way to create a subclass where tag is writable. Is there any suggestion about how I should write the subclass? thanks 回答1: public class MyNSView : NSView { public nint _tag; public new nint Tag { get { return _tag; } set { _tag = value; } } Be aware that this is not longer the NSView Tag. Using your custom NSView Tag

Undoing and Redoing NSView Object Move Made by NSPanGestureRecognizer

二次信任 提交于 2020-01-16 08:36:32
问题 I am working on a sample desktop application to test the UndoManager class, which I don't often get to use. Anyway, the following is the idea. I create two NSView sub view objects (red & blue). They are added to an IBOutlet-connected NSView object (panView). I add the pan gesture ( NSPanGestureRecognizer ) to these two sub view objects. The applications calls the undo manager when the user moves either sub view object. The following is my entire code from top to bottom. import Cocoa class

Forwarding drag & drop event to parent view

ε祈祈猫儿з 提交于 2020-01-13 19:01:32
问题 I have an application where I have one custom view which is derived from NSView. Within this view, there are several custom subviews, which are also derived from NSView. I want to implement a drag and drop behavior which allows URLs to be dropped onto the views. Everything is already working for the main view. So, actually I would have to implement dragging behavior handlers on the child-views and the parent-view class. The thing is, that I don't want to copy the complete handling code to all

Mouse Events Bleeding Through NSView

守給你的承諾、 提交于 2020-01-13 09:57:07
问题 I have an NSView which covers its parent window's content view. This view has a click event handler which removes it from the content view. Inside this view, I have another view. When I drag the mouse in this inner view, the mouse events are applied not only to the view in the front, but also to the views behind. Additionally, the cursors from the views behind are showing up as well. This is the same problem occurring here: NSView overlay passes mouse events to underlying subviews? but the

Mouse Events Bleeding Through NSView

▼魔方 西西 提交于 2020-01-13 09:57:06
问题 I have an NSView which covers its parent window's content view. This view has a click event handler which removes it from the content view. Inside this view, I have another view. When I drag the mouse in this inner view, the mouse events are applied not only to the view in the front, but also to the views behind. Additionally, the cursors from the views behind are showing up as well. This is the same problem occurring here: NSView overlay passes mouse events to underlying subviews? but the

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

青春壹個敷衍的年華 提交于 2020-01-12 04:44:09
问题 Basically I would like to test a chart drawing in a Swift playground in NSView. 回答1: Here is what I am using now: class CustomView: NSView { init(frame: NSRect) { super.init(frame: frame) } override func drawRect(dirtyRect: NSRect) { color.setFill() NSRectFill(self.bounds) NSColor.yellowColor().setFill() var r = NSMakeRect(0, y, self.bounds.width, 5) NSRectFill(r) } var color = NSColor.greenColor() var y: CGFloat = 0 } var view = CustomView(frame: NSRect(x: 0, y: 0, width: 300, height: 300))