Re: Command-click table in background app SOLVED
Re: Command-click table in background app SOLVED
- Subject: Re: Command-click table in background app SOLVED
- From: Bill Cheeseman <email@hidden>
- Date: Fri, 02 Jun 2006 06:53:12 -0400
- Thread-topic: Command-click table in background app SOLVED
on 2006-06-01 8:32 AM, Bill Cheeseman at email@hidden wrote:
> The solution is to subclass NSTableView and override -mouseDown: to deal
> differently with a Command-click when the application is in the background,
> like so:
>
> @implementation PFClickthroughTableView
>
> - (void)mouseDown:(NSEvent *)event {
> if (![NSApp isActive] && ([event modifierFlags] & NSCommandKeyMask)) {
> int row = [self rowAtPoint:[self convertPoint:[event
> locationInWindow] fromView:nil]];
> if ([[self delegate] tableView:self shouldSelectRow:row]) {
> [self selectRowIndexes:[NSIndexSet indexSetWithIndex:row]
> byExtendingSelection:NO];
> [self sendAction:[self action] to:nil];
> }
> return;
> }
> [super mouseDown:event];
> }
>
> @end
The -sendAction:to: method is better sent like this:
[self sendAction:[self action] to:[self target];
-- in case the target is not in the responder chain. In IB, of course, the
"custom class" of the table must be set to PFClickthroughTableView and the
table must be connected to its action method.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
PreFab Software - http://www.prefab.com/scripting.html
The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden