!ScrollPane methodsFor: '*StandardYellowButtonMenus-scroll bar events' stamp: 'nk 1/23/2004 14:22'! hasYellowButtonMenu ^getMenuSelector notNil! ! !Morph methodsFor: '*StandardYellowButtonMenus-event handling' stamp: 'nk 3/10/2004 19:48'! handlerForYellowButtonDown: anEvent "Return the (prospective) handler for a mouse down event with the yellow button pressed. The handler is temporarily installed and can be used for morphs further down the hierarchy to negotiate whether the inner or the outer morph should finally handle the event." (self hasYellowButtonMenu or: [ self handlesMouseDown: anEvent ]) ifFalse: [ ^ nil]. "Not interested." anEvent handler ifNil: [^ self]. "Nobody else was interested" "Same priority but I am innermost." ^ self mouseDownPriority >= anEvent handler mouseDownPriority ifFalse: [nil ] ifTrue: [self]! ! !Morph methodsFor: '*StandardYellowButtonMenus-menus' stamp: 'nk 3/10/2004 19:49'! addMyYellowButtonMenuItemsToSubmorphMenus "Answer true if I have items to add to the context menus of my submorphs" ^true! ! !Morph methodsFor: '*StandardYellowButtonMenus-menus' stamp: 'nk 3/10/2004 19:50'! hasYellowButtonMenu "Answer true if I have any items at all for a context (yellow button) menu." ^self models anySatisfy: [ :m | m hasModelYellowButtonMenuItems ]! ! !Morph methodsFor: '*StandardYellowButtonMenus-event handling-override' stamp: 'nk 3/10/2004 19:47'! handlerForMouseDown: anEvent "Return the (prospective) handler for a mouse down event. The handler is temporarily installed and can be used for morphs further down the hierarchy to negotiate whether the inner or the outer morph should finally handle the event." anEvent blueButtonPressed ifTrue: [^ self handlerForBlueButtonDown: anEvent]. anEvent yellowButtonPressed ifTrue: [^ self handlerForYellowButtonDown: anEvent]. anEvent controlKeyPressed ifTrue: [^ self handlerForMetaMenu: anEvent]. (self handlesMouseDown: anEvent) ifFalse: [^ nil]. "not interested" anEvent handler ifNil: [^ self ]. "Same priority but I am innermost" "Nobody else was interested" ^self mouseDownPriority >= anEvent handler mouseDownPriority ifTrue: [ self] ifFalse: [ nil]! ! !Morph methodsFor: '*StandardYellowButtonMenus-menus' stamp: 'nk 6/15/2004 07:11'! addGraphModelYellowButtonItemsTo: aCustomMenu event: evt ^aCustomMenu! ! !Morph methodsFor: '*StandardYellowButtonMenus-menus' stamp: 'nk 3/10/2004 19:50'! addYellowButtonMenuItemsTo: aCustomMenu event: evt "Populate aCustomMenu with appropriate menu items for a yellow-button (context menu) click." aCustomMenu defaultTarget: self; addStayUpItem. self addModelYellowButtonItemsTo: aCustomMenu event: evt! ! !Morph methodsFor: '*StandardYellowButtonMenus-menus' stamp: 'nk 3/10/2004 19:45'! addNestedYellowButtonItemsTo: aMenu event: evt "Add items to aMenu starting with me and proceeding down through my submorph chain, letting any submorphs that include the event position contribute their items to the bottom of the menu, separated by a line." self addYellowButtonMenuItemsTo: aMenu event: evt. (self submorphThat: [:m | m containsPoint: evt position] ifNone: []) ifNotNilDo: [:m | | submenu | (m addMyYellowButtonMenuItemsToSubmorphMenus and: [m hasYellowButtonMenu]) ifTrue: [aMenu addLine. submenu := MenuMorph new defaultTarget: m. m addNestedYellowButtonItemsTo: submenu event: evt. aMenu add: m externalName subMenu: submenu]]! ! !Morph methodsFor: '*StandardYellowButtonMenus-event handling' stamp: 'nk 6/24/2004 13:19'! yellowButtonActivity: shiftState "Find me or my outermost owner that has items to add to a yellow button menu. shiftState is true if the shift was pressed. Otherwise, build a menu that contains the contributions from myself and my interested submorphs, and present it to the user." | aMenu outerOwner | outerOwner := self outermostOwnerWithYellowButtonMenu. outerOwner ifNil: [ ^self ]. outerOwner ~~ self ifTrue: [^outerOwner yellowButtonActivity: shiftState ]. aMenu := MenuMorph new defaultTarget: self. aMenu addTitle: self externalName. self addNestedYellowButtonItemsTo: aMenu event: ActiveEvent. aMenu popUpInWorld: self currentWorld. ! ! !Morph methodsFor: '*StandardYellowButtonMenus-menus' stamp: 'nk 6/15/2004 07:23'! addModelYellowButtonItemsTo: aCustomMenu event: evt "Give my models a chance to add their context-menu items to aCustomMenu." self model ifNotNilDo: [ :m | m addModelYellowButtonMenuItemsTo: aCustomMenu forMorph: self hand: evt hand. aCustomMenu addLine]. ^aCustomMenu! ! !Morph methodsFor: '*StandardYellowButtonMenus-model access' stamp: 'nk 3/10/2004 19:51'! models "Answer a collection of whatever models I may have." self modelOrNil ifNil: [ ^EmptyArray ]. ^Array with: self modelOrNil! ! !Morph methodsFor: '*StandardYellowButtonMenus-menus' stamp: 'nk 3/10/2004 19:51'! outermostOwnerWithYellowButtonMenu "Answer me or my outermost owner that is willing to contribute menu items to a context menu. Don't include the world." | outermost | outermost _ self outermostMorphThat: [ :ea | ea isWorldMorph not and: [ ea hasYellowButtonMenu ]]. ^outermost ifNil: [ self hasYellowButtonMenu ifTrue: [ self ] ifFalse: []] ! ! !PasteUpMorph methodsFor: '*standardyellowbuttonmenus-event handling' stamp: 'nk 1/23/2004 16:29'! hasYellowButtonMenu ^self isWorldMorph ! ! !PasteUpMorph methodsFor: '*standardyellowbuttonmenus-misc' stamp: 'nk 1/23/2004 16:25'! addMyYellowButtonMenuItemsToSubmorphMenus ^self isPartsBin! ! !Object methodsFor: '*standardyellowbuttonmenus-graph model' stamp: 'dgd 8/26/2004 14:58'! addModelYellowButtonMenuItemsTo: aCustomMenu forMorph: aMorph hand: aHandMorph "The receiver serves as the model for aMorph; a menu is being constructed for the morph, and here the receiver is able to add its own items" Preferences cmdGesturesEnabled ifTrue: [ "build mode" aCustomMenu add: 'inspect model' translated target: self action: #inspect. ]. ^aCustomMenu ! ! !Object methodsFor: '*standardyellowbuttonmenus-graph model' stamp: 'nk 1/23/2004 14:35'! hasModelYellowButtonMenuItems ^Preferences cmdGesturesEnabled! ! !TwoWayScrollPane methodsFor: '*standardyellowbuttonmenus-menu' stamp: 'nk 1/23/2004 15:29'! hasYellowButtonMenu ^getMenuSelector notNil! !