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

Re: buttonType in NSButton


  • Subject: Re: buttonType in NSButton
  • From: "Adam Lindsay" <email@hidden>
  • Date: Wed, 11 Dec 2002 00:26:21 +0000

>> I'm working on my first significant Cocoa project, and was wondering if
>> there's a programmatic way of discovering an NSButton's buttonType. I've
>> looked at NSButton, NSButtonCell, and NSAccessibility (briefly), and
>> nothing presents itself as the front door. I can *set* it, but I don't
>> want to do that.
>>
>
>How about asking the button for its class, e.g. [yourButton class] or
>[yourButton className], or testing with isKindOfClass:? Check the NSObject
>docs.

Perhaps I misunderstood you, but my premise was that [myButton class] is
not enough to distinguish between an NSButton that momentarily lights and
one that toggles.

But I did try this one-liner based on your advice, just in case. The
Outlet "type" goes to an NSTextField and the Action "query" is received
from any number of NSControls:

- (IBAction)query:(id)sender
{
[type setObjectValue:[[sender class] description]];
}

The results are as expected: Sliders are NSSliders, a Pop-up Button is an
NSPopUpButton. Any button, from a check box to an "ok"-style button is an
NSButton.

These different varieties of button are enumerated by NSButtonType within
AppKit/NSButtonCell.h. There is a method to *set* the buttonType, but
there is no supported method to inspect the buttonType. I want to inspect
it, and that's where I'm stumped.

But thanks for giving a stab at my problem.

Cheers,
adam

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Adam Lindsay +44(0)1524 594 537
email@hidden
http://www.comp.lancs.ac.uk/computing/users/atl/
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
_______________________________________________
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: buttonType in NSButton
      • From: Jonathan Jackel <email@hidden>
  • Prev by Date: Re: Modifying dyld behavior for framework
  • Next by Date: Initializing NSOpenGLViews
  • Previous by thread: RE: buttonType in NSButton
  • Next by thread: Re: buttonType in NSButton
  • Index(es):
    • Date
    • Thread