nsview

How to customize IKImageBrowserView to add a NSButton on each item?

删除回忆录丶 提交于 2019-12-02 01:49:23
问题 I want to customize IKImageBrowserView so that i can add NSButton or other control on cell of IKImageBrowserView. I tried to cutomize IKBrowserViewCell class, but i did not get how and where i add NSbutton, So that it display on IKBrowserViewItem. Here is the code i had tried till now. #import "ImageBrowserView.h" #import "ImageBrowserCell.h" - (IKImageBrowserCell *) newCellForRepresentedItem:(id) cell { return [[ImageBrowserCell alloc] init]; } In cell class - (CALayer *) layerForType:

How to customize IKImageBrowserView to add a NSButton on each item?

独自空忆成欢 提交于 2019-12-02 01:48:44
I want to customize IKImageBrowserView so that i can add NSButton or other control on cell of IKImageBrowserView. I tried to cutomize IKBrowserViewCell class, but i did not get how and where i add NSbutton, So that it display on IKBrowserViewItem. Here is the code i had tried till now. #import "ImageBrowserView.h" #import "ImageBrowserCell.h" - (IKImageBrowserCell *) newCellForRepresentedItem:(id) cell { return [[ImageBrowserCell alloc] init]; } In cell class - (CALayer *) layerForType:(NSString*) type { CGColorRef color; //retrieve some usefull rects NSRect frame = [self frame]; NSRect

Can't CTRL+Drag NSButton to custom NSView header

心已入冬 提交于 2019-12-02 00:48:31
I'd like to create a custom NSTableCellView instantiated by Interface Builder. I've set my Table Cell View class to MyTableCellView , and properly created MyTableCellView : NSTableCellView .m/.h files. However, I just can't CTRL+Drag a simple button from inside this view to MyTableCellView.h in order to create an IBOutlet . Here is a video to show what happens: http://youtu.be/sNNbuVT-SZs . How the view is subclassed: How I try to CTRL+Drag a button Also, sometimes, Interface Builder just don't allow the cell view's class to be modified. What's happening ? I finally found a solution, that is a

Multiple views layouting in NSScrollView using Visual AutoLayout

淺唱寂寞╮ 提交于 2019-12-01 23:50:27
I need to show multiple views aligned vertically inside NSScrollView , I started by adding NSTableView and NSButton . I aligned them vertically with NSTableView on top and NSButton on bottom. I added NSTableview and NSButton to an NSView called tempView . And then set the document view of NSScrollView to tempView . But problem i am having is my tableview does not expand properly i see the buttons alright but tablview does not expands properly and just show the last entries that fits in the table. As you can see in following image it displays last 4 rows of 20 rows. ] My code is as follow -

Rounded corners on NSTableView

♀尐吖头ヾ 提交于 2019-12-01 12:07:28
I have a custom view subclass similar to NSBox that draws a rounded box background. The problem is that if I place a view like an NSTableView in the box view, it does not clip to the rounded corners. Is there any way to round the corners of NSTableView and its parent scroll view? I haven't tried this with a table view but have with other controls. In a subclass of NSTableView (or whatever view/control you want to clip) Override drawRect: Create an NSBezierPath with the shape you want (probably appendBezierPathWithRoundedRect:xRadius:yRadius: just remember to use the view's bounds as the size)

How to display shadow for NSView?

一曲冷凌霜 提交于 2019-12-01 04:18:43
I have gone through many threads here and other blogs but not able to solve this issue. I have a added a subview in content view of window. Here is the storyboard-- - I have dragged out outlet of customView to view controller and here is the code for view controller - import Cocoa import QuartzCore class ViewController: NSViewController { @IBOutlet weak var customView: NSView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. self.view.wantsLayer = true self.customView.wantsLayer = true self.customView.layer?.backgroundColor = NSColor.redColor

Detect left and right mouse click on NSView

北城余情 提交于 2019-12-01 03:53:43
In Swift: I created a simple NSView and now want to execute different functions, depending on which mouseButton is pressed (left or right). how can I detect this? Warren Burton You trap the corresponding mouseDown events import Cocoa class MyView : NSView { override func mouseDown(theEvent : NSEvent) { println("left mouse") } override func rightMouseDown(theEvent : NSEvent) { println("right mouse") } } See NSResponder for more magic. Swift 4 import Cocoa class MyView : NSView { override func mouseDown(with theEvent: NSEvent) { print("left mouse") } override func rightMouseDown(with theEvent:

How to display shadow for NSView?

北城余情 提交于 2019-12-01 01:54:49
问题 I have gone through many threads here and other blogs but not able to solve this issue. I have a added a subview in content view of window. Here is the storyboard-- - I have dragged out outlet of customView to view controller and here is the code for view controller - import Cocoa import QuartzCore class ViewController: NSViewController { @IBOutlet weak var customView: NSView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. self.view

Detect left and right mouse click on NSView

自作多情 提交于 2019-12-01 00:36:26
问题 In Swift: I created a simple NSView and now want to execute different functions, depending on which mouseButton is pressed (left or right). how can I detect this? 回答1: You trap the corresponding mouseDown events import Cocoa class MyView : NSView { override func mouseDown(theEvent : NSEvent) { println("left mouse") } override func rightMouseDown(theEvent : NSEvent) { println("right mouse") } } See NSResponder for more magic. Swift 4 import Cocoa class MyView : NSView { override func mouseDown

WebView Insert / Modify Content dynamically

折月煮酒 提交于 2019-11-30 16:13:05
In my application, i am using WebView to display the content, Now is it possible to modify the content dynamically, the requirement is something like this, i will get info from network and depending upon them i need to set the style/font/attribute or probably i need to append the new text when the connected device is not responding, So far i am using following code, -(void)modifyString:(NSString *)string{ [sourceString stringByAppendingString:errorString :string] } -(void)reloadPage{ [[pWebView mainFrame] loadHTMLString:htmlString baseURL:nil]; } I don’t think its correct way to implement it,