Sunday, May 28, 2006


And, finally, a few hours later, .NET checkboxes and radiobuttons. Suprisingly, .NET took a similar approach to Cocoa, coupling UI with management of radio groups by requiring developers to wrap radio buttons in a container widget. This necessitated the same approach - using my RadioGroupManager to support mutual inclusion among radio buttons in a group.

For a while, I feared that the .NET implementation would be a deal-killer. The documentation stated that all radio buttons in the same form (i.e., with the same parent) would be mutually exclusive. Tests showed this to be true (you can see this in the above figure, where only one radio button on the page was selected). Clicking on buttons in radio group 1 cleared any selections in radio group 2, and vice-versa. The documentation then went on to declare that in order to define radio groups, you had to manage them in a GroupBox or Panel, which would have had huge implications on my layout engine. This was worse than Cocoa -- in Cocoa, if you didn't wrap them in a NSMatrix widget, no problem -- things were left alone. No true with .NET, mutual exclusion is built in, like it or not.

Luckily, after playing around with things awhile, I discovered that there is a property on radio buttons that allows me to take them out of any management scheme, thereby allowing me to reuse RadioGroupManager exactly as it was designed for use with Cocoa radiobuttons. All I had to do was set the .NET RadioButton "AutoCheck" property to false when creating the RadioButton widget concrete instance.

Phew, that was a close one :-) RadioButtons were, in the end, a very interesting exercise, one that really stress-tested my overall design.

0 Comments:

Post a Comment

<< Home