'From Squeak3.3alpha of 12 January 2002 [latest update: #4741] on 3 February 2002 at 5:16:55 pm'! "Change Set: textEditMenus-sw Date: 3 February 2002 Author: Scott Wallace Text-editing menus in morphic, whether invoked via yellow-button, via clicking on a halo handle, or by clicking on the menu icon the scroll bar, now do *not* allow keyboard-menu-control, so that the text selection to which the menu items apply will remain visible as the menu is being used."! !MenuMorph methodsFor: 'modal control' stamp: 'sw 2/3/2002 14:26'! invokeModal "Invoke this menu and don't return until the user has chosen a value. See example below on how to use modal menu morphs." ^ self invokeModal: Preferences menuKeyboardControl "Example: | menu sub entry | menu _ MenuMorph new. 1 to: 3 do: [:i | entry _ 'Line', i printString. sub _ MenuMorph new. menu add: entry subMenu: sub. #('Item A' 'Item B' 'Item C') do:[:subEntry| sub add: subEntry target: menu selector: #modalSelection: argument: {entry. subEntry}]]. menu invokeModal. " ! ! !MenuMorph methodsFor: 'modal control' stamp: 'sw 2/3/2002 14:26'! invokeModal: allowKeyboardControl "Invoke this menu and don't return until the user has chosen a value. If the allowKeyboarControl boolean is true, permit keyboard control of the menu" ^ self invokeModalAt: ActiveHand position in: ActiveWorld allowKeyboard: allowKeyboardControl! ! !PluggableTextMorph methodsFor: 'menu commands' stamp: 'sw 2/3/2002 16:55'! scrollBarMenuButtonPressed: event "The menu button in the scrollbar was pressed; put up the menu" | menu | (menu _ self getMenu: event shiftPressed) ifNotNil: ["Set up to use perform:orSendTo: for model/view dispatch" menu setInvokingView: self. menu invokeModal: false]! ! !PluggableTextMorph methodsFor: 'menu commands' stamp: 'sw 2/3/2002 16:33'! yellowButtonActivity "Called when the shifted-menu's 'more' item is chosen" | menu | (menu _ self getMenu: false) ifNotNil: ["Set up to use perform:orSendTo: for model/view dispatch" menu setInvokingView: self. menu invokeModal: false]! ! !PluggableTextMorph methodsFor: 'scroll bar events' stamp: 'sw 2/3/2002 16:29'! yellowButtonActivity: shiftKeyState "Invoke the text-editing menu" | menu | (menu _ self getMenu: shiftKeyState) ifNotNil: [menu setInvokingView: self. menu invokeModal: false]! ! !StrikeFont class methodsFor: 'instance creation' stamp: 'sw 2/3/2002 13:29'! fromUser: priorFont "Present a menu of available fonts, and if one is chosen, return it." | fontList fontMenu style active ptMenu label spec font | fontList _ StrikeFont familyNames remove: 'DefaultTextStyle' ifAbsent: []; asOrderedCollection. fontMenu _ MenuMorph new defaultTarget: self. fontList do: [:fontName | style _ TextStyle named: fontName. active _ priorFont familyName sameAs: fontName. ptMenu _ MenuMorph new defaultTarget: self. style pointSizes do: [:pt | (active and:[pt = priorFont pointSize]) ifTrue:[label _ ''] ifFalse:[label _ '']. label _ label, pt printString, ' pt'. ptMenu add: label target: fontMenu selector: #modalSelection: argument: {fontName. pt}]. active ifTrue:[label _ ''] ifFalse:[label _ '']. label _ label, fontName. fontMenu add: label subMenu: ptMenu]. spec _ fontMenu invokeModal: false. "don't allow keyboard control" spec ifNil: [^ nil]. style _ TextStyle named: spec first. style ifNil: [^ self]. font _ style fonts detect: [:any | any pointSize = spec last] ifNone: [nil]. ^ font! !