• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSPopUpButtonCell Keeps on Trackin'! Demo, Movie
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSPopUpButtonCell Keeps on Trackin'! Demo, Movie


  • Subject: Re: NSPopUpButtonCell Keeps on Trackin'! Demo, Movie
  • From: Jerry Krinock <email@hidden>
  • Date: Sun, 26 Apr 2009 07:41:37 -0700

Well, even after distilling into a tiny demo, I still can't figure this one out. A popup menu attached to a regular button works fine. But when using it as an NSTableHeaderCell, it keeps tracking the mouse even after it's closed.

How can one work around this?

Here's a 30-second movie:

   http://sheepsystems.com/engineering/projects/KOT/KeepOnTrackin.mov

and the tiny demo project (56 KB):

   http://sheepsystems.com/engineering/projects/KOT/KeepOnTrackin.zip

and finally, for those who would rather just look at the code:


#import "KOTAppDel.h"


@implementation KOTAppDel

// Start a ticking timer.  When the timer pauses, we'll know
// that one of our popup menus is tracking the mouse.
- (void)applicationDidFinishLaunching:(NSNotification*)note {
    [NSTimer scheduledTimerWithTimeInterval:1.0
                                     target:self
                                   selector:@selector(tick)
                                   userInfo:nil
                                    repeats:YES] ;
}

- (void)tick {
    NSLog(@"tick") ;
}

- (void)logChoice:(id)sender {
    NSLog(@"You clicked \"%@\"", [sender title]) ;
}

- (NSMenu*)makeMenu {
    NSMenu* menu = [[NSMenu alloc] init] ;
    NSArray* choices = [NSArray arrayWithObjects:
                        @"Me",
                        @"Oh",
                        @"My",
                        nil] ;
    for (NSString* choice in choices) {
        NSMenuItem* item ;
        item = [[NSMenuItem alloc] init] ;
        [item setRepresentedObject:choice] ;
        [item setTitle:choice] ;
        [item setAction:@selector(logChoice:)] ;
        [menu addItem:item] ;
        [item release] ;
    }

    return [menu autorelease] ;
}

- (void)awakeFromNib {
    [table setDelegate:self] ;
}

// Action method for the button
- (IBAction)buttonClicked:(id)sender {
    NSPopUpButtonCell* popUpCell = [[NSPopUpButtonCell alloc] init] ;

    [popUpCell setMenu:[self makeMenu]] ;
    [popUpCell performClickWithFrame:NSZeroRect
                                 inView:sender] ;
    [popUpCell release] ;
}

// Table View delegate method.
// A little more complicated since we have to dig into the
// parts of the table, and assign it as a header cell.
- (void)               tableView:(NSTableView*)tableView
  mouseDownInHeaderOfTableColumn:(NSTableColumn *)tableColumn {
    NSTableHeaderView *headerView = [tableView headerView] ;

    NSPopUpButtonCell* popUpCell = [[NSPopUpButtonCell alloc] init] ;
    [tableColumn setHeaderCell:popUpCell] ;

    [popUpCell setMenu:[self makeMenu]] ;
    [popUpCell performClickWithFrame:NSZeroRect
                          inView:headerView] ;
    [popUpCell release] ;
}

@end


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSPopUpButtonCell Keeps on Trackin'! Demo, Movie
      • From: Jim Correia <email@hidden>
References: 
 >NSPopUpButtonCell causes UI to "sleep" when clicked (From: Jerry Krinock <email@hidden>)
 >Re: NSPopUpButtonCell causes UI to "sleep" when clicked (From: Peter Ammon <email@hidden>)

  • Prev by Date: Re: FSPathCopyObjectSync and symbolic links?
  • Next by Date: Re: Trying to get flagsChanged: to work
  • Previous by thread: Re: NSPopUpButtonCell causes UI to "sleep" when clicked
  • Next by thread: Re: NSPopUpButtonCell Keeps on Trackin'! Demo, Movie
  • Index(es):
    • Date
    • Thread