• 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: Newbie query re default buttons
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie query re default buttons


  • Subject: Re: Newbie query re default buttons
  • From: Robert Cerny <email@hidden>
  • Date: Thu, 22 May 2008 19:53:43 +0200

Hi,
could you send me your project off list? I will check it and let you know what's wrong. (If I find it of course)


Robert

On 22.5.2008, at 19:39, Michael McLaughlin wrote:

Robert Cerny wrote:

Just FYI,
[myButton setKeyEquivalent:@"\r"]; is the correct way to set button to
Default. Are you sure that speakButton is not nil?

The button is OK.

I found that I could get the button to work by entering the Return key
equivalent in IB, stubbing out awakeFromNib. However, the *appearance* of
the button is still non-default.


Also, Hillegass instructs to set up the FirstResponder of the window to
point to the textField. I had done that earlier and thought that it might
be interefing so I eliminated it along with the entire textField in IB, then
made a new textField without messing with FirstResponder. I found that the
textField behaves just as though the FirstResponder still existed (perhaps
this is a new default behavior with a single textField). The button
appearance was not fixed.


So, right now, the button works as though it were the default (thanks to the
IB key equivalent field) but it does not *look* like a default button. I
searched again for some difference in what I did vs. what the
BackgroundExporter code looks like and cannot find any real differences.
Moreover, the debugger behaves as though all it well -- no errors, no nil
outlets.


BTW, all of this is with Xcode 3.0 and OS 10.5.2.

On 22.5.2008, at 16:51, Michael McLaughlin wrote:

As a Cocoa newbie (after years of Carbon), I am working my way
through the
3rd edition of Hillegass' book. I finished his SpeakLine example then
thought I'd challenge myself by making the Speak button the default
button
-- but failed.


I coded the following

*** AppController.h

@interface AppController : NSObject {
  IBOutlet NSTextField *textField;
  NSSpeechSynthesizer *speechSynth;

  IBOutlet NSView *windView;          <-- content view, added
  IBOutlet NSButton *speakButton;     <-- added
}

- (IBAction)sayIt:(id)sender;
- (IBAction)stopIt:(id)sender;
@end

*** added to AppController.m

- (void)awakeFromNib {
  [[speakButton window] setDefaultButtonCell:[speakButton cell]];

  // debugging
  NSButtonCell *def = nil;
  def = [[speakButton window] defaultButtonCell];
}

I made the connections in IB to both windView and speakButton and
they look
OK (compared to those in Apple's BackgroundExporter sample code. I
tried
using the content view as well as the button itself to get the window.
Neither works. My button is not blue or pulsing and the Return key
does
nothing. The def variable *does* get the correct result (judging by
self
variables). Using windView to get the window does not help.

-- Mike McLaughlin


_______________________________________________

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


References: 
 >Re: Newbie query re default buttons (From: Michael McLaughlin <email@hidden>)

  • Prev by Date: Re: What is an id?
  • Next by Date: Re: What is an id?
  • Previous by thread: Re: Newbie query re default buttons
  • Next by thread: Fighting NSCollectionView for first Responder
  • Index(es):
    • Date
    • Thread