Inherits from Box
The ChooseOneBox class allows you to create a collection of switches, such as check boxes or toggle switches, only one of which can be turned on at any time. The ChooseOneBox object ensures that only one (or none) of its switch subviews is on. If the user touches a switch that's off, ththat switch is turned on and the switch that was previously on goes off.
A ChooseOneBox object can contain other items in addition to switches. These other items aren't affected by the ChooseOneBox's rule of mutual exclusivity for switches. The switches need not be of the same type (as in the choose-one box in the lower left of the illustration), though you should probably avoid confusing your users with a mishmash of switches.
Instantiate: sometimes Subclass: rarely Call its methods: rarely
Class ChooseOneBox is a direct descendant of class Box, adding the methods that allow only one contained switch to be on at once. You can add or remove ChooseOneBox contents by using standard construction features. Any switches dropped into a ChooseOneBox object are automatically and immediately subject to the box's mutual exclusivity rule.
The ChooseOneBox class doesn't add any additional fields beyond those provided by its superclasses, and it only defines a few methods of its own.
Class ChooseOneBox defines the following methods:
Method | Description |
---|---|
ChangedContents |
Overridden to take action when a new switch is added to box |
CurrentChoice | Returns the current choice in the box |
ValueChangeNotice | Overridden to force other switches off when one turns on |
Class ChooseOneBox defines no fields.
You'll rarely have to call or override any methods of class ChooseOneBox.
overrides ChangedContents(whatCausedChange: Object) Call: rarely Override: rarely
Magic Cap calls ChangedContents when an object moves from one superview to another, to give both the old superview and the new superview a chance to perform some action. ChooseOneBox_ChangedContents uses this notification to learn when a new switch has been dropped into the box.
See Viewable_ChangedContents for more information.
operation CurrentChoice(): Object Call: rarely Override: rarely
Call CurrentChoice to get the switch inside the ChooseOneBox that's turned on. The ChooseOneBox's mutual exclusivity rule ensures that only one switch is on. If no switch is turned on, GetCurrentChoice returns nilObject.
overrides ValueChangeNotice Call: rarely Override: rarely
Call ValueChangeNotice to notify a viewable that the value of one of its subviews has changed.
When a switch changes its value, usually because of a user's touch, the switch calls its superview's ValueChangeNotice method to give the superview a chance to perform some action. ChooseOneBox_ValueChangeNotice enforces the box's mutual exclusivity rule, forcing all other switches off if a switch was just turned on. ChooseOneBox_ValueChangeNotice calls EnforceMutEx to perform part of its action.
See Viewable_ValueChangeNotice for more information.