Re: buttonType in NSButton
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.