views:

451

answers:

2

Hi Guys I have been trying this for past few days but couldnt figure it out.

I have an application which has a NSOutlineView and a NSTableView. Outlineview takes input a path and displays them in the form of a tree structure its sub contents. So when ever a user clicks on a particular folder in the outine view, the contents of the folder should be displayed in the table view with their attributes in the form of a list.

Now i am able to display in both the views respective contents and the interaction between the outlineview and tableview is done using delegates and notifications.

Now my problem is I want to have mouse events to be detected in both the views so that i can make my app more interactive by enabling single click to select, double click to enable opening the file/folder and control+click to enable a contextual pop up menu. but strangely no mouse events are getting detected.

my design of the app is pretty simple with each of table and outline views having their own view and controller class and interactions between them using notifications. Please can you guys suggest me where i am going wrong?

I know i can get single click and double click to work using setAction and DoubleAction methods of table view but i cannot get control click to work. I want to know whats wrong with my app design as non of my views are detecting mouse events :(

Thanks

A: 

You can get whether Control is pressed with:

if([[NSApp currentEvent] modifierFlags] & NSControlKeyMask){
    //control was pressed at the time the event was posted
}

Or you might want to subclass the NSTableView/NSOutlineView and override mouseDown: to get the event directly.

Also, if your action and doubleAction aren't working, verify that the target/action are correct with something like:

NSAssert([[theView target] respondsToSelector:[theView doubleAction]], @"target/action is wrong");
Tom Dalling
A: 

Thanks Tom for the reply. I have subclassed my NSTableView to detect the events but they were not getting detected.

Sorry for not being clear in the question but my action and double action are working fine but i cannot handle control click case with them. so i wanted to detect mouse and also in future keyboard events to make my app more interactive.

Thanks

King