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

Newbie query re default buttons


  • Subject: Newbie query re default buttons
  • From: Michael McLaughlin <email@hidden>
  • Date: Thu, 22 May 2008 10:51:07 -0400
  • Thread-topic: Newbie query re default buttons

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.

Calling
[speakButton setKeyEquivalent:@"\r"];
did not work either.

Even though my code and the BackgroundExporter seem the same to me, I am
obviously missing something.

Any tips, from anyone?

TIA.

--
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

  • Follow-Ups:
    • Re: Newbie query re default buttons
      • From: Robert Cerny <email@hidden>
    • Re: Newbie query re default buttons
      • From: Robert Cerny <email@hidden>
  • Prev by Date: CoreData Statement Still Active (CoreData Multithreading)
  • Next by Date: Re: NSTExtView
  • Previous by thread: Re: PMSessionEndDocumentNoDialog error code -43
  • Next by thread: Re: Newbie query re default buttons
  • Index(es):
    • Date
    • Thread