Search code examples
objective-ccocoansviewnsviewcontroller

load NSPanel from NSView


I'm trying to load a NSPanel when to send message when something happen in the NSView. But I can not figure out how to call the NSPanel from the NSView or how to call a method from the NSView class

Here is how I'm loading the NSView:

NSViewController *myVC = [[songView alloc] initWithNibName:@"songView" bundle:nil];

My question for you guys is how can access or call methods from the NSView class to my NSWindowController.

I'll really appreciate your help.


Solution

  • You can catch the mouseDown event and call your method . For the NSPanel you can do in 2 ways

    1) You can create in IB and put an outlet connection to panel

    2) You can create in programetically .

    You can call orderFront to bring it front. Please refer this link for that https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindow_Class/index.html#//apple_ref/doc/uid/20000013-SW32