Squeak Class Documentation category index | class index  
 
MenuMorph
  category: Morphic-Menus
  superclass: AlignmentMorph
  subclasses: DumberMenuMorph MVCMenuMorph UpdatingMenuMorph

Instance variables:
defaultTarget <Object> The default target for creating menu items
selectedItem <MenuItemMorph> The currently selected item in the receiver
stayUp <Boolean> True if the receiver should stay up after clicks
popUpOwner <MenuItemMorph> The menu item that automatically invoked the receiver, if any.
activeSubMenu <MenuMorph> The currently active submenu.

instance methods
  accessing
  allWordings
allWordingsNotInSubMenu:
commandKeyHandler
commandKeyHandler:
defaultTarget
hasSubMenu:
itemWithWording:
items
lastItem
lastSelection
popUpOwner
popUpOwner:
rootMenu
stayUp
stayUp:
titleGuesstimate

  construction
  add:action:
add:selector:argument:
add:subMenu:
add:target:action:
add:target:selector:
add:target:selector:argument:
add:target:selector:argumentList:
addLine
addList:
addStayUpItem
addStayUpItemSpecial
addTitle:
addTitle:updatingSelector:updateTarget:
addUpdating:action:
addUpdating:enablement:action:
addUpdating:enablementSelector:target:selector:argumentList:
addUpdating:target:action:
addUpdating:target:selector:argumentList:
addWithLabel:enablement:action:
addWithLabel:enablementSelector:target:selector:argumentList:
balloonTextForLastItem:
defaultTarget:
labels:lines:selections:
title:

  control
  activeSubmenu:
deleteIfPopUp:
isCandidateForAutomaticViewing
popUpAdjacentTo:forHand:from:
popUpAt:forHand:in:
popUpEvent:in:
popUpForHand:in:
popUpInWorld
popUpInWorld:
selectItem:event:
wantsToBeDroppedInto:

  copying
  veryDeepFixupWith:
veryDeepInner:

  drawing
  drawOn:

  dropping/grabbing
  justDroppedInto:event:
undoGrabCommand

  events
  activate:
handleFocusEvent:
handlesMouseDown:
mouseDown:
mouseUp:

  initialization
  delete
initialize
setDefaultParameters
setTitleParametersFor:

  keyboard control
  displayFiltered:
handlesKeyboard:
keyStroke:
keyboardFocusChange:
moveSelectionDown:event:

  layout
 

  menu
  addCustomMenuItems:hand:
addItem
addTitle
detachSubMenu:
setInvokingView:
setTarget:
toggleStayUp:
toggleStayUpIgnore:evt:

  private
  invokeMetaMenu:
morphicLayerNumber
positionAt:relativeTo:inWorld:
selectedItem

class methods
  example
  example

  instance creation
  entitled:

instance methods
  accessing top  
 

allWordings

Answer a collection of the wordings of all items and subitems, omitting debug menu


 

allWordingsNotInSubMenu:

Answer a collection of the wordings of all items and subitems, but omit the stay-up item, and also any items in a submenu whose tag is given by erbotenSubmenuContents


 

commandKeyHandler

Answer the receiver's commandKeyHandler


 

commandKeyHandler:

Set the receiver's commandKeyHandler. Whatever you set here needs to be prepared to respond to the message #commandKeyTypedIntoMenu:


 

defaultTarget


 

hasSubMenu:


 

itemWithWording:

If any of the receiver's items or submenu items have the given wording (case-blind comparison done), then return it, else return nil.


 

items


 

lastItem


 

lastSelection

Return the label of the last selected item or nil.


 

popUpOwner

Return the current pop-up owner that is the menu item that automatically initiated the receiver.


 

popUpOwner:

Set the current pop-up owner


 

rootMenu


 

stayUp


 

stayUp:


 

titleGuesstimate


  construction top  
 

add:action:

Append a menu item with the given label. If the item is selected, it will send the given selector to the default target object.


 

add:selector:argument:


 

add:subMenu:

Append the given submenu with the given label.


 

add:target:action:


 

add:target:selector:

Append a menu item with the given label. If the item is selected, it will send the given selector to the target object.


 

add:target:selector:argument:

Append a menu item with the given label. If the item is selected, it will send the given selector to the target object with the given argument.


 

add:target:selector:argumentList:

Append a menu item with the given label. If the item is selected, it will send the given selector to the target object with the given arguments. If the selector takes one more argument than the number of arguments in the given list, then the triggering event is supplied as as the last argument. Answer the appended menu item.


 

addLine

Append a divider line to this menu. Suppress duplicate lines.


 

addList:

Add the given items to this menu, where each item is a pair (<string> <actionSelector>).. If an element of the list is simply the symobl $-, add a line to the receiver. The optional third element of each entry, if present, provides balloon help.


 

addStayUpItem

Append a menu item that can be used to toggle this menu's persistence.


 

addStayUpItemSpecial

Append a menu item that can be used to toggle this menu's persistent.


 

addTitle:

Add a title line at the top of this menu.


 

addTitle:updatingSelector:updateTarget:

Add a title line at the top of this menu Make aString its initial contents. If aSelector is not nil, then periodically obtain fresh values for its contents by sending aSelector to aTarget..


 

addUpdating:action:


 

addUpdating:enablement:action:


 

addUpdating:enablementSelector:target:selector:argumentList:

Append a menu item with the given label. If the item is selected, it will send the given selector to the target object with the given arguments. If the selector takes one more argument than the number of arguments in the given list, then the triggering event is supplied as as the last argument. In this variant, the wording of the menu item is obtained by sending the wordingSelector to the target, and the optional enablementSelector determines whether or not the item should be enabled. Answer the item itself.


 

addUpdating:target:action:


 

addUpdating:target:selector:argumentList:

Append a menu item with the given label. If the item is selected, it will send the given selector to the target object with the given arguments. If the selector takes one more argument than the number of arguments in the given list, then the triggering event is supplied as as the last argument. In this variant, the wording of the menu item is obtained by sending the wordingSelector to the target, Answer the item added.


 

addWithLabel:enablement:action:


 

addWithLabel:enablementSelector:target:selector:argumentList:

Append a menu item with the given label. If the item is selected, it will send the given selector to the target object with the given arguments. If the selector takes one more argument than the number of arguments in the given list, then the triggering event is supplied as as the last argument. In this variant, the wording of the menu item is constant, and the optional enablementSelector determines whether or not the item should be enabled.


 

balloonTextForLastItem:


 

defaultTarget:

Set the default target for adding menu items.


 

labels:lines:selections:

This method allows the receiver to accept old-style SelectionMenu creation messages. It should be used only for backward compatibility during the MVC-to-Morphic transition. New code should be written using the other menu construction protocol such as addList:.


 

title:

Add a title line at the top of this menu.


  control top  
 

activeSubmenu:


 

deleteIfPopUp:

Remove this menu from the screen if stayUp is not true. If it is a submenu, also remove its owning menu.


 

isCandidateForAutomaticViewing


 

popUpAdjacentTo:forHand:from:

Present this menu at the given point under control of the given hand.


 

popUpAt:forHand:in:

Present this menu at the given point under control of the given hand.


 

popUpEvent:in:

Present this menu in response to the given event.


 

popUpForHand:in:

Present this menu under control of the given hand.


 

popUpInWorld

Present this menu in the current World


 

popUpInWorld:

Present this menu under control of the given hand.


 

selectItem:event:


 

wantsToBeDroppedInto:

Return true if it's okay to drop the receiver into aMorph


  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:

Draw the menu. Add keyboard-focus feedback if appropriate


  dropping/grabbing top  
 

justDroppedInto:event:

This message is sent to a dropped morph after it has been dropped on -- and been accepted by -- a drop-sensitive morph


 

undoGrabCommand

Return an undo command for grabbing the receiver


  events top  
 

activate:

Receiver should be activated; e.g., so that control passes correctly.


 

handleFocusEvent:

Handle focus events. Valid menu transitions are determined based on the menu currently holding the focus after the mouse went down on one of its children.


 

handlesMouseDown:

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


 

mouseDown:

Handle a mouse down event.


 

mouseUp:

Handle a mouse up event.
Note: This might be sent from a modal shell.


  initialization top  
 

delete

Remove the receiver as a submorph of its owner and make its new owner be nil.


 

initialize


 

setDefaultParameters


 

setTitleParametersFor:


  keyboard control top  
 

displayFiltered:


 

handlesKeyboard:

Answer whether the receiver handles the keystroke represented by the event


 

keyStroke:

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


 

keyboardFocusChange:

Notify change due to green border for keyboard focus


 

moveSelectionDown:event:

Move the current selection up or down by one, presumably under keyboard control.
direction = +/-1


  layout top  

  menu top  
 

addCustomMenuItems:hand:

Add morph-specific items to the given menu which was invoked by the given hand. This method provides is invoked both from the halo-menu and from the control-menu regimes.


 

addItem


 

addTitle


 

detachSubMenu:


 

setInvokingView:

Re-work every menu item of the form
<target> perform: <selector>
to the form
<target> perform: <selector> orSendTo: <invokingView>.
This supports MVC's vectoring of non-model messages to the editPane.


 

setTarget:

Set the default target object to be used for add item commands, and re-target all existing items to the new target or the the invoking hand.


 

toggleStayUp:

Toggle my 'stayUp' flag and adjust the menu item to reflect its new state.


 

toggleStayUpIgnore:evt:

This variant is resistant to the MVC compatibility in #setInvokingView:


  private top  
 

invokeMetaMenu:


 

morphicLayerNumber

helpful for insuring some morphs always appear in front of or behind others.
smaller numbers are in front


 

positionAt:relativeTo:inWorld:

Note: items may not be laid out yet (I found them all to be at 0@0),
so we have to add up heights of items above the selected item.


 

selectedItem


class methods
  example top  
 

example

MenuMorph example


  instance creation top  
 

entitled:

Answer a new instance of me with the given title.