Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sivaprakash

macrumors member
Original poster
Mar 10, 2011
52
0
Chennai, India
Hi

I am using NSPanel in my application to build Modal Dialogue, but I am wondering whenever I want to handle some events it always goes to parent class but not Panel's class. I have created a Class and refereed from .NIB Object Interface.

Can you please tell how can handle Panel's control's events in Panel class itself.

Thanks
Siva
 

jiminaus

macrumors 65816
Dec 16, 2010
1,449
1
Sydney
Normally Cocoa is not programmed directly in terms of events, but instead in terms of actions sent to targets.

For example, instead of trying to code for the mouse down event on a button, you'd normally set the button's action and target so the button sends a particular action message to a particular target object when it's clicked.

Or maybe I'm being too literal with the terminology you're using in your question.

Can you tell us more about what your trying to do?
 

sivaprakash

macrumors member
Original poster
Mar 10, 2011
52
0
Chennai, India
Hi

What I am trying to do is, When user clicks Login button there should be a window (Panel) comes out till the user respond to that Panel he/she should not be allowed to access other part of application.

But when ever I add panel to NIB the action target always goes to parent window's ".m" file not Panel's class. Can you please explain me how to direct the control to Panel's class rather parent's.

Thanks
Siva
 

jiminaus

macrumors 65816
Dec 16, 2010
1,449
1
Sydney
Have a look at the attached project. It shows 2 windows, a PanelTest window and an "Other Window" window. You might need to Cmd+` to see both windows after running in XCode.

You'll notice that you can click the Click Me button in the other window. When you do you'll see a message in the debugger console.

If you click the Login button in the PanelTest window, a login sheet will show. While the login sheet is showing, you can't click the Click Me button in the other window.

If you untick the Sheet checkbox, the login button will show a separate modal window, as opposed to a sheet.

The guts of all this is in LoginPanelController.

Note: This is an abuse of the term Panel. The login window is not an NSPanel. It's an NSWindow. Panels are used to implement secondary windows, like the Library window in Interface Builder in XCode 3 (not like the one in XCode 4).
 

Attachments

  • PanelTest.zip
    34.1 KB · Views: 78
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.