• 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: NSButton behavior
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSButton behavior


  • Subject: Re: NSButton behavior
  • From: Stéphane Sudre <email@hidden>
  • Date: Sun, 20 Jun 2004 21:43:59 +0200

On dimanche, juin 20, 2004, at 07:18 PM, Herr Witten wrote:

I programmatically created a button like this:

NSButton* button = [[[NSButton alloc] init] autorelease];
[button setTitle: @"Cancel"];
[button setTarget: self];
[button setAction: @selector(cancelSheet:)];
[button sizeToFit];

for a sheet. It gave me a NeXTish style button that worked just fine.
So, I figured I would beautify it with this:

[button setBezelStyle: NSRoundedBezelStyle];

and indeed the Aqua style button appeared, but the button border was
broken in the middle, shifted downward. I decided to sidestep the
problem by having the button be the default button so that it would
redraw itself with a pulse. I therefore added these calls:

[button setBezelStyle: NSRoundedBezelStyle];
[button setKeyEquivalent: @"\r"];

And voil`! The button appeared broken momentarily, but the pulsing
immediately redrew it. However, when I clicked on other buttons in the
sheet, the program hung, and when I just clicked the "Cancel" button,
the sheet disappeared, so I conjured another and closed it with the
"Cancel" button, which caused a hang--always on the second closing.

These problems do not occur with the NeXTish style button. Thanks for
any help.

I hope you won't bang your head against the wall after reading this:

Instead of calling [ sizeToFit] before [ setBezelStyle: NSRoundedBezelStyle], just call it after.

Additional suggestions:

* forget the autorelease call, just add the button to the superview and then release it.

* Use NSLocalizedString(@"Cancel",@"Think localized") instead of @"Cancel"

* Use initWithFrame instead of init
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: NSButton behavior
      • From: Herr Witten <email@hidden>
References: 
 >NSButton behavior (From: Herr Witten <email@hidden>)

  • Prev by Date: Re: App launch problem
  • Next by Date: Re: App launch problem
  • Previous by thread: NSButton behavior
  • Next by thread: Re: NSButton behavior
  • Index(es):
    • Date
    • Thread