views:

15

answers:

1

hey,

i am stuck on one problem that i am not able to solve. I have a CourtView : NSView in which i can draw and where it stores my mouseDownPoint and mouseUpPoint. And I have a WindowManager : NSObject which has CourtView as an IBOutlet CourtView *courtView;

What i want to do is that as soon as the mouse is released, so - (void)mouseUp:(NSEvent *)event; is called, a method in WindowManager is called.

Thanks for your help, Dewy

A: 

You need to give CourtView a reference to the WindowManager instance so that it can call through to it in the mouseUp method. There are several ways to do this, but given that you already use an IBOutlet to link them the other way, probably the simplest is to do the same in reverse.

Add an IBOutlet instance variable to the interface of CourtView:

@class WindowManager;
@interface CourtView : NSView
{
    IBOutlet WindowManager* manager;

    // ... rest of your interface ...
}

In Interface Builder, you should now be able add a connection between this outlet in your CourtView and the existing WindowManager object. Then, in the implementation for CourtView, have your event handler send the relevant message to manager:

- (void) mouseUp:(NSEvent*) event
{
    // ...

    [manager someWindowManagerMethodWithEvent:event andOtherArgument:whatever];

    // ...
}
walkytalky