Squeak Class Documentation category index | class index  
 
PluggableButtonView
  category: ST80-Pluggable Views
  superclass: View
  subclasses:

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:

getStateSelector fetch a boolean value from the model
actionSelector invoke this button's action on the model

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.

Options:
askBeforeChanging have model ask user before allowing change that could lose edits
triggerOnMouseDown do button action on mouse down (vs. up) transition
shortcutCharacter a place to record an optional shortcut key

instance methods
  accessing
  action:
askBeforeChanging
askBeforeChanging:
label
label:
shortcutCharacter
shortcutCharacter:
triggerOnMouseDown
triggerOnMouseDown:

  controller access
  defaultControllerClass

  displaying
  deEmphasizeView
display
displayComplemented
displayNormal
displayView
emphasizeView
toggleMouseOverFeedback

  initialize-release
  initialize
on:getState:action:label:menu:

  other
  defaultWindow
performAction
update:
window:

  private
  centerAlignLabelWith:
centerLabel
getMenu:
getModelState
insetDisplayBox

class methods
  example
  example

  instance creation
  on:
on:getState:action:
on:getState:action:label:
on:getState:action:label:menu:

instance methods
  accessing top  
 

action:

Set actionSelector to be the action defined by aSymbol.


 

askBeforeChanging


 

askBeforeChanging:

If this preference is turned on, then give the model an opportunity to ask the user before accepting a change that might cause unaccepted edits to be lost.


 

label

Answer the DisplayObject used as this button's label.


 

label:

Label this button with the given String or DisplayObject.


 

shortcutCharacter

Return the Character to be used as a shortcut to turn on this switch, or nil if this switch doesn't have a keyboard shortcut.


 

shortcutCharacter:

Set the character to be used as a keyboard shortcut for turning on this switch.


 

triggerOnMouseDown


 

triggerOnMouseDown:

If this preference is turned on, then trigger my action immediately when the mouse goes down.


  controller access top  
 

defaultControllerClass

Answer the class of the default controller for the receiver. Subclasses
should redefine View|defaultControllerClass if the class of the default
controller is not Controller.


  displaying top  
 

deEmphasizeView

Subclasses should redefine View|deEmphasizeView in order to modify
the emphasis (highlighting, special tabs) of particular objects associated
with the View such as labels, lines, and boxes.


 

display

Sets the PluggableButtonView mode to 'normal', displays the border, displays the inside and, if its model is 'on', complements the inside.


 

displayComplemented

Complement the receiver if it isn't already.


 

displayNormal

Complement the receiver if its mode is 'complemented'.


 

displayView

Displays this switch and its label, if any.


 

emphasizeView

Subclasses should redefine View|emphasizeView in order to modify
the emphasis (highlighting, special tabs) of particular objects associated
with the View such as labels, lines, and boxes.


 

toggleMouseOverFeedback

Complement the label (or a portion of the displayBox if no label is defined) to show that the mouse is over this button. This feedback can be removed by a second call to this method.


  initialize-release top  
 

initialize

Initialize the state of the receiver. Subclasses should include 'super
initialize' when redefining this message to insure proper initialization.


 

on:getState:action:label:menu:


  other top  
 

defaultWindow

Return a rectangle large enough to contain this button's label. If this button is label-less, just return the standard View default window.


 

performAction

Inform the model that this button has been pressed. Sent by the controller when this button is pressed.


 

update:

Normally sent by the receiver's model in order to notify the receiver of
a change in the model's state. Subclasses implement this message to do
particular update actions. A typical action that might be required is to
redisplay the receiver.


 

window:

Center my label when my window changes.


  private top  
 

centerAlignLabelWith:

Align the center of the label with aPoint.


 

centerLabel

If there is a label, align its center with the center of the insetDisplayBox


 

getMenu:

Answer the menu for this view, supplying an empty menu to be filled in. If the menu selector takes an extra argument, pass in the current state of the shift key.


 

getModelState

Answer the result of sending the receiver's model the getStateSelector message.


 

insetDisplayBox

Answer the receiver's inset display box. The inset display box is the
intersection of the receiver's window, tranformed to display coordinates,
and the inset display box of the superView, inset by the border width.
The inset display box represents the region of the display screen in
which the inside of the receiver (all except the border) is displayed. If
the receiver is totally clipped by the display screen and its superView,
the resulting Rectangle will be invalid.


class methods
  example top  
 

example

PluggableButtonView example


  instance creation top  
 

on:


 

on:getState:action:


 

on:getState:action:label:


 

on:getState:action:label:menu: