Squeak Class Documentation category index | class index  
 
PluggableButtonMorph
  category: Morphic-Windows
  superclass: AlignmentMorph
  subclasses:

A PluggableButtonMorph 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
getLabelSelector fetch this button's lable from the model
getMenuSelector fetch a pop-up menu for this button from the model

Any 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 its view(s) 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 a change that could lose edits
triggerOnMouseDown do this button's action on mouse down (vs. up) transition
shortcutCharacter a place to record an optional shortcut key

instance methods
  accessing
  action:
actionSelector
askBeforeChanging
askBeforeChanging:
feedbackColor:
label
label:
label:font:
model:
offColor
offColor:
onColor:offColor:
shortcutCharacter
shortcutCharacter:
triggerOnMouseDown
triggerOnMouseDown:

  copying
  veryDeepFixupWith:
veryDeepInner:

  drawing
  drawOn:

  events
  handlesMouseDown:
mouseDown:
mouseMove:
mouseUp:
updateFeedbackForEvt:

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

  private
  getMenu:
getModelState
invokeMenu:
performAction

  updating
  update:

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.


 

actionSelector

Answer the receiver's actionSelector


 

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.


 

feedbackColor:

Set the color of this button's selection feedback border.


 

label

Answer the DisplayObject used as this button's label.


 

label:

Label this button with the given string or morph.


 

label:font:

Label this button with the given string or morph.


 

model:

Set my model and make me me a dependent of the given object.


 

offColor


 

offColor:

Set the fill colors to be used when this button is off.


 

onColor:offColor:

Set the fill colors to be used when this button is on/off.


 

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.


  copying top  
 

veryDeepFixupWith:

If fields were weakly copied, fix them here. If they were in the tree being copied, fix them up, otherwise point to the originals!!


 

veryDeepInner:

Copy all of my instance variables. Some need to be not copied at all, but shared. Warning!! Every instance variable defined in this class must be handled. We must also implement veryDeepFixupWith:. See DeepCopier class comment.


  drawing top  
 

drawOn:


  events top  
 

handlesMouseDown:

Do I want to receive mouseDown events (mouseDown:, mouseMove:, mouseUp:)?


 

mouseDown:

Details: If this button is triggered on mouse down or the event is the menu gesture, handle it immediately. Otherwise, make a list of buttons (including the receiver) for mouseMove feedback. This allows a simple radio-button effect among the button submorphs of a given morph.


 

mouseMove:

Handle a mouse move event. The default response is to let my eventHandler, if any, handle it.


 

mouseUp:

Handle a mouse up event. The default response is to let my eventHandler, if any, handle it.


 

updateFeedbackForEvt:


  initialize-release top  
 

initialize


 

on:getState:action:label:menu:


  private top  
 

getMenu:

Answer the menu for this button, 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.


 

invokeMenu:

Invoke my menu in response to the given event.


 

performAction

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


  updating top  
 

update:

Receive a change notice from an object of whom the receiver is a
dependent. The default behavior is to do nothing; a subclass might want
to change itself in some way.


class methods
  example top  
 

example

PluggableButtonMorph example openInWorld


  instance creation top  
 

on:


 

on:getState:action:


 

on:getState:action:label:


 

on:getState:action:label:menu: