• 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
Custom NSButton on toolbar
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Custom NSButton on toolbar


  • Subject: Custom NSButton on toolbar
  • From: Fredrik Olsson <email@hidden>
  • Date: Fri, 30 Jun 2006 13:55:35 +0200

I have a NSButton with a custom NSButtonCell that implements a delayed popup menu. More or less the same code as used by Camino.

It works, but with two glitches:
1. When disabled the label is not grayed.
If I toggle to Icon only and then back to Icon and text, the text is grayed. But not if visible from start.
And if the Application is not the in fron the button, but not the text becomes enabled...
Strangeness. Any documentation of special handling for custom views in toolbars available?


2. It do not resize when selecting size small.
Adding a plain NSButton works, but not my own.
Full code for creating the button here (More or less the same as in Camino but sequential):


NSToolbarItem *composeItem = [[MTValidatedToolbarItem alloc] initWithItemIdentifier:@"ComposeMessage"];
[composeItem setTarget:self];
[composeItem setAction:@selector(newMessage:)];
[composeItem setLabel:MTLocalizedString(@"ComposeMessage")];
[composeItem setPaletteLabel:[composeItem label]];


   MTDelayedButtonCell *cell = [[MTDelayedButtonCell alloc] init];
   [cell setTarget:[composeView target]];
   [cell setAction:[composeView action]];
   [cell setClickHoldAction:@selector(newMessagePopUp:)];

NSButton *button = [[NSButton alloc] initWithFrame:NSMakeRect(0.,0.,32.,32.)];
[button setCell:cell];
[button setBezelStyle: NSRegularSquareBezelStyle];
[button setButtonType: NSMomentaryChangeButton];
[button setBordered: NO];
[button setImagePosition: NSImageOnly];
NSImage *icon = [NSImage imageNamed:@"ComposeMessagePopUp"];
[icon setScalesWhenResized:YES];
[button setImage:icon];


   [composeItem setView:composeView];
   [composeItem setMinSize:NSMakeSize(32.0,32.0)];
   [composeItem setMaxSize:NSMakeSize(32.0,32.0)];
   [composeItem setTag:0];


// Fredrik Olsson _______________________________________________ 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
  • Prev by Date: RE: Sorting an NSTableView by code
  • Next by Date: Compositing to custom view in Cocoa
  • Previous by thread: Re: First Responder target?
  • Next by thread: Compositing to custom view in Cocoa
  • Index(es):
    • Date
    • Thread