Re: buttonType in NSButton
Re: buttonType in NSButton
- Subject: Re: buttonType in NSButton
- From: "Adam Lindsay" <email@hidden>
- Date: Wed, 11 Dec 2002 09:14:19 +0000
I believe Jonathan Jackel said this around Tue, 10 Dec 2002:
>
I'm not a big user of different button styles, so I may be wrong here, but
>
the docs say that when you set a button type, you are changing the button's
>
behavior for highlightsBy and showsStateBy. Those are iVars you can access.
>
[myButton highLightsBy] and [myButton showsStateBy] will return an integer
>
representing how the button behaves (see the corresponding "set" methods for
>
the lists of constants). Once you figure out the values returned by the
>
button types you are using, you can test for them and, by implication, for
>
the type of button you are dealing with.
Bingo. Just the hint I was looking for. NSButtonCell is what has a
showsStateBy method, so I learned about the relationship between Controls
and Cells, and then it all became clear. So a test for a button that
toggles would be:
[[myButton cell] showsStateBy] != NSNoCellMask
I've learned at least two Cocoa lessons in the process:
1) Don't check for class or type when it's behavior you really want to
know about.
2) Do check further up the class hierarchy for the concepts or methods
relevant to your problem.
>
As usual, I didn't quite get what the problem was.
As usual, I had trouble expressing my problem precisely enough the first
time around.
Many thanks,
adam
>
on 12/10/02 7:26 PM, Adam Lindsay at email@hidden wrote:
>
>
>>> 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.
>
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
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.