Account Options

  1. Sign in
Google Groups Home
« Groups Home
Radio Button and Checkbox API
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Francisco Tolmasky  
View profile  
 More options May 16 2009, 7:07 pm
From: Francisco Tolmasky <franci...@280north.com>
Date: Sat, 16 May 2009 16:07:03 -0700 (PDT)
Local: Sat, May 16 2009 7:07 pm
Subject: Radio Button and Checkbox API
I've just committed the beginnings of radio and checkbox buttons and
wanted to quickly discuss the API since it is a bit different from
Cocoa's.  The main issue arrises from the fact that Cappuccino doesn't
have cells and that in Cocoa checkboxes and radio buttons are just
normal buttons with their images/alt. images set to radio/checkbox
images.

In Cappuccino we decided to stray from this for a number of reasons:

1. As stated before, we don't have cells so we can't and shouldn't
make use of NSMatrix to control the interaction between radio buttons.
2. In Cocoa, there is no reasonable way to ask a button whether it is
no a radio or checkbox -> the closest thing you can do is [[button
image] name] isEqualTo:@"NSCheckBox"], which is not the most elegant
thing in the universe.
3. In Cocoa, you can't have a checkbox or radio with an image, since
the image is already in use to show the actual checkbox/radio UI. In
other words, [myCheckBox setImage:someOptionImage] will make the
checkmark UI go away.

So, what we've done is create the CPRadio and CPCheckBox classes. This
allows us to make them separately themable from normal buttons, and
allows us to actually ask a button if its a radio/checkbox
(isKindOfClass:[CPCheckBox class]).

Creating a checkbox is easy enough:

checkbox = [[CPCheckBox alloc] initWithFrame:aFrame];

That's basically all there is to it. Radio buttons are very similar,
the key difference is the introduction of a new class CPRadioGroup,
which defines which radio buttons are part of the same group:

[myRadioButton setRadioGroup:aRadioGroup];

Every radio button receives a unique radio group by default (so if you
do nothing further, they will all behave independently), but you can
use an existing radio button's group with other buttons as so:

button1 = [[CPRadio alloc] initWithFrame:aFrame];
...
button2 = [[CPRadio alloc] initWithFrame:aFrame radioGroup:[button1
radioGroup]];
...
button3 = [[CPRadio alloc] initWithFrame:aFrame radioGroup:[button1
radioGroup]];
...etc...

Here, all the radio buttons will act "together". [[button1 radioGroup]
allRadios] returns every button that's part of this group, and
[[button1 radioGroup] selectedRadio] returns the currently selected
option.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrew Burkhalter  
View profile  
 More options May 18 2009, 5:10 pm
From: Andrew Burkhalter <andrewburkhal...@gmail.com>
Date: Mon, 18 May 2009 14:10:14 -0700
Local: Mon, May 18 2009 5:10 pm
Subject: Re: Radio Button and Checkbox API

I've looked this over and used within my own proof-of-concept project and
all works as advertised and looks quite nice.  Thanks for tackling this!
My only comments/questions are minor:

* For both radio and checkbox, the radio-bezel and radio-bezel-selected
images repeat behind the entirety of the title.  Investigating the DOM, i
can easily fix an instance in place by setting 'background-repeat' to
'no-repeat' as opposed to initial which is the default in a recent WebKit
nightly.  Investigating a bit further, I see ThemeDescriptors.j creates a
CPColor using the class method "colorWithPatternImage" which as expected
sets _cssString to something that would lead to a repeated background.  Am I
missing something obvious or shall I log a bug against this?

* I don't have major comments about abandoning a more Cocoa-like API, but
having looked in ThemeDescriptors.j for example use and having overlooked
the "Designated Initializer" comment within CPRadio.j, I'd vote for some
liberal copy paste of this email to steer future users that haven't seen
this post towards radioGroup usage and why it's important and why abandoning
the Cocoa-way makes more sense here.  I can add a bug for this as well, if
desired.

Thanks!

Andrew

On Sat, May 16, 2009 at 4:07 PM, Francisco Tolmasky
<franci...@280north.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Häcker  
View profile  
 More options May 19 2009, 4:18 am
From: Martin Häcker <mhaec...@mac.com>
Date: Tue, 19 May 2009 10:18:03 +0200
Local: Tues, May 19 2009 4:18 am
Subject: Re: Radio Button and Checkbox API

> 1. As stated before, we don't have cells so we can't and shouldn't
> make use of NSMatrix to control the interaction between radio buttons.
> 2. In Cocoa, there is no reasonable way to ask a button whether it is
> no a radio or checkbox -> the closest thing you can do is [[button
> image] name] isEqualTo:@"NSCheckBox"], which is not the most elegant
> thing in the universe.

I didn't have time to do this myself, but I think we could have a  
liberal look at what the iPhone API does as it also abandons Cells (as  
far as I know).

Doing that may allow us to stay more compatible in design with cocoa -  
even if we have to go other ways in implementation.

Regards,
Martin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Emanuele Vulcano  
View profile  
 More options May 19 2009, 4:22 am
From: Emanuele Vulcano <millen...@gmail.com>
Date: Tue, 19 May 2009 10:22:22 +0200
Local: Tues, May 19 2009 4:22 am
Subject: Re: Radio Button and Checkbox API
The iPhone has no checkboxes at all; on/off switches are used instead.  
— ev

Il giorno 19/mag/2009, alle ore 10.18, Martin Häcker  
<mhaec...@mac.com> ha scritto:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »