I have an app with 2 separate NSWindow loaded.

Each window has one small table with two items in it.

Here's the problem i cant seem to solve -->

If window #1 is active/focused, i can click on the individual rows in the table normally. But if i want to click the rows in the table within window #2, I have to click the table twice. The first click to get Window #2 in active/focused, and finally the second click to actually select the row.

How can i get to select the rows in the NSTableViews in only one click (regardless if their windows are in focus or not) ?

有帮助吗?

解决方案

I sub-classed the NSTableView.

-(BOOL)acceptsFirstMouse:(NSEvent *)theEvent {
   return YES;
}

其他提示

Create an IBOutlet of your NSTableView as:

IBOutlet NSTableView* yourTable;

Bind it to your table.

Then use:

[window2 makeFirstResponder: yourTable];

The problem is when your first window is active as it is first responder so obviously your tableview will be the next responder of window1 until you select it. But for second window your first responder will be window2. So you have to double click on the table twice because first responder is setting to window2 and it is setting to table 2 for making next responder. If you want to do single click and select table of window2 then you can do through binding or programmatically as well.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top