Squeak Class Documentation category index | class index  
 
Switch
  category: Tools-Menus
  superclass: Model
  subclasses: OneOnSwitch Button

I represent a selection setting and actions to take depending on a change in the setting. An instance has three attributes: state, which is either on or off; on action; and off action. The on and off actions are blocks of code that execute whenever the instance changes state. I am typically used as a menu item in conjunction with a SwitchView and a SwitchController.
1/24/96 sw: made this a subclass of Model, for faster dependents handling

instance methods
  action
  doAction:
offAction:
onAction:

  private
  initializeOff
initializeOn

  state
  clear
isOff
isOn
set
switch
turnOff
turnOn

class methods
  instance creation
  new
newOff
newOn

instance methods
  action top  
 

doAction:

Execute anAction if it is non-nil.


 

offAction:

Set the off action of the receiver to anAction.


 

onAction:

Set the on action of the receiver to anAction.


  private top  
 

initializeOff


 

initializeOn


  state top  
 

clear

Set the state of the receiver to 'off'. If the state of the receiver was
previously 'on', then 'self change' is sent. The receiver's off action is
NOT executed.


 

isOff

Answer whether the receiver is set off or not.


 

isOn

Answer whether the receiver is set on or not.


 

set

Set the state of the receiver to 'on'. If the state of the receiver was
previously 'off', then 'self change' is sent. The receiver's on action is
NOT executed.


 

switch

Change the state of the receiver from 'on' to 'off' or from 'off' to 'on' (see
Switch|turnOn, Switch|turnOff).


 

turnOff

Set the state of the receiver to 'off'. If the state of the receiver was
previously 'on', then 'self change' is sent and the receiver's off action is
executed.


 

turnOn

Set the state of the receiver to 'on'. If the state of the receiver was
previously 'off', then 'self change' is sent and the receiver's on action is
executed.


class methods
  instance creation top  
 

new

Answer an instance of me such that the on and off actions are set to nil
('no action'), and the state is set to 'off'.


 

newOff

Answer an instance of me such that the on and off actions are set to nil
('no action'), and the state is set to 'off'.


 

newOn

Answer an instance of me such that the on and off actions are set to nil
('no action'), and the state is set to 'on'.