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

eivindd

macrumors newbie
Original poster
Mar 12, 2009
4
0
I have a window with 5 QTMovieView in it. I am trying to return the index of the respective QTMovieview by using the NSEvent: mouseUp. With index of the QTMovieView, I mean the index I have assigned by interface builder. Is this possible?
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Can't you subclass QTMovieView and handle the mouseUp: event there? If not, please describe what you're trying to do.
 

eivindd

macrumors newbie
Original poster
Mar 12, 2009
4
0
I have subclassed QTMovieView and overrided the mouseUp: event there. The problem however is how to get the correct QTMovieView index (I have 5 of them). For example, if i click inside QtmovieView number 1, I would like to get this index.
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
This index you're referring to isn't a real number, it's just how you perceive them visually. You need to actually define this value somewhere. Usually this is referred to as a tag, but a QTMovieView doesn't have a tag, so you need to come up with something here. Subclassing and creating a tag accessor could work, or declaring them as IBOutlets and referring to them there, etc. You also need to have the mouseUp: event call back to your controller. Usually this is done via delegates.
 

eivindd

macrumors newbie
Original poster
Mar 12, 2009
4
0
Thank you for explaining this to a newbie ;)
My QTMovieViews is already declared as IBOutlets. Is there an easy solution to refer to them from the NSEvent:mouseUp method?
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Here is one way to do it, which makes a few assumptions about your nib.

In your QTMovieView subclass, declare an IBOutlet ivar for your controller. Then in IB, connect each view's ivar to the controller. In your controller, declare a method in the .h and implement it in the .m for handling the mouse up event, for example:
Code:
- (void)handleMovieViewClick:(QTMovieView *)sender
{
    if (sender == movieView1)
        ...
    else if (...)
        ...
}
Then your mouseUp: event could be:
Code:
- (void)mouseUp:(NSEvent *)event
{
    [controller handleMouseViewClick:self];
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.