Re: Currency Converter (tyler, you there ?)
Re: Currency Converter (tyler, you there ?)
- Subject: Re: Currency Converter (tyler, you there ?)
- From: Carlos Weber <email@hidden>
- Date: Sun, 28 Oct 2001 08:41:11 -1000
On Sunday, October 28, 2001, at 06:21 , Irwin Poche wrote:
>
In the July archives there's a posting from "tyler" asking why a line of
>
Currency Converter only worked when the button Convert is clicked, as
>
opposed to pressing Return...
>
>
[rateField selectText:self];
>
>
I am having exactly the same problem and do not find a solution in the
>
archives.
>
>
I know it's not a coding goof on mine or tyler's part. I've downloaded
>
the
>
O'Reilly Learning Cocoa examples which includes Currency Converter and
>
it
>
exhibits exactly the same symptom.
>
>
Anyone know what's going on with this?
How about the following instance method of NSWindow:
- (void)setDefaultButtonCell:(NSButtonCell *)aButtonCell
Makes aButtonCell's key equivalent the Return (or Enter) key, so when
the user presses Return that button performs as if clicked. See the
method description for defaultButtonCell for more information.
Here's an example of it's use in a project of mine:
[[self window]setDefaultButtonCell: [[self createButton]cell]];
I am calling this from my NSWindowController object (self); notice that
you have to ask the associated _window_ to perform the method, and that
the "target" has to be the _cell_ associated with the particular button
you want to be the default. By the way, this will also get you the
pulsing blue behavior that standard Aqua default buttons have.