Contents

Class PluggableButtonView


Inheritance:

Object  »
  View  »
    PluggableButtonView

A PluggableButtonView is a combination of an indicator for a boolean value stored in its model and an action button. The action of a button is often, but not always, to toggle the boolean value that it shows.

Preferred controller class: PluggableButtonController.
Possible model classes:

Instance variables:

Important Class Methods

For the creation of initialized instances, the class protocol provides a set of five dedicated class methods. Method on:getState:action:label:menu: is the most general of these methods, three others are shortened variants that provide reasonable default values for some parameters of the general method.

A PluggableButtonView is a combination of an indicator for a boolean value stored in its model and an action button. The action of a button is often, but not always, to toggle the boolean value that it shows. Its pluggable selectors are:

Either of the above selectors can be nil, meaning that the model does not supply behavior for the given action, and the default behavior should be used. For example, if getStateSelector is nil, then this button shows the state of a read-only boolean that is always false.

The model informs a pluggable view of changes by sending #changed: to itself with getStateSelector as a parameter. The view tells the model when the button is pressed by sending actionSelector.

A PluggableButtonView can display either a Form or one of the following: String, Text, DisplayText, Paragraph.

Options:

For proper placement of a DisplayObject, a PluggableButtonView assign a value to the instance variable offset. It is therefore not possible to share a Form or a DisplayText between several instances of PluggableButtonView.

To display the text on a switch in a larger font, you should create a DisplayText. The following piece of code may serve as a template:

   | text textStyle displayText |

  text := Text string: string
               attribute: TextEmphasis normal.

  textStyle := TextStyle default copy.
  textStyle defaultFontIndex: (textStyle fontIndexOfSize: 21).

  displayText := DisplayText text: text
                             textStyle: textStyle.
  displayText foregroundColor: Color black
              backgroundColor: Color lightGreen.

  switch label: displayText

Contents