[prev in list] [next in list] [prev in thread] [next in thread]
List: squeak-dev
Subject: Re: How do you make a Morph communicate with several other Morphs?
From: Bruce Cohen <cohenb () gemstone ! com>
Date: 1998-04-29 20:52:10
[Download RAW message or body]
> > How do you make a button Morph tell three StringMorphs to change their contents?
Just for grins, I reconstructed the MultiTargetButtonMorph:
'From Squeak 1.31 of Feb 4, 1998 on 29 April 1998 at 12:45:29 pm'!
SimpleButtonMorph subclass: #MultiTargetButtonMorph
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Morphic-Widgets'!
!MultiTargetButtonMorph methodsFor: 'initialization' stamp: 'bc 4/29/98 12:19'!
initialize
super initialize.
target := OrderedCollection new.! !
!MultiTargetButtonMorph methodsFor: 'events' stamp: 'bc 4/29/98 12:38'!
doButtonAction
"Perform the action of this button. Subclasses may override this method. The default \
behavior is to send the button's actionSelector to its target object with its \
arguments."
(target ~~ nil and: [actionSelector ~~ nil]) ifTrue: [
Cursor normal showWhile: [
target do: [ :item | item perform: actionSelector withArguments: arguments]]].
! !
!MultiTargetButtonMorph methodsFor: 'menu' stamp: 'bc 4/29/98 12:35'!
addCustomMenuItems: aCustomMenu hand: aHandMorph
super addCustomMenuItems: aCustomMenu hand: aHandMorph.
((self world rootMorphsAt: aHandMorph targetOffset) size > 1) ifTrue: [
aCustomMenu add: 'add to target' action: #addToTarget:.
aCustomMenu add: 'remove from target' action: #removeFromTarget:].
! !
!MultiTargetButtonMorph methodsFor: 'menu' stamp: 'bc 4/29/98 12:21'!
addToTarget: evt
| rootMorphs |
rootMorphs _ self world rootMorphsAt: evt hand targetOffset.
rootMorphs size > 1
ifTrue: [target addLast: (rootMorphs at: 2)]
ifFalse: [^ self].
! !
!MultiTargetButtonMorph methodsFor: 'menu' stamp: 'bc 4/29/98 12:21'!
removeFromTarget: evt
| rootMorphs |
rootMorphs _ self world rootMorphsAt: evt hand targetOffset.
rootMorphs size > 1
ifTrue: [target remove: (rootMorphs at: 2)]
ifFalse: [^ self].
! !
!MultiTargetButtonMorph methodsFor: 'menu' stamp: 'bc 4/29/98 12:27'!
setTarget: evt
| rootMorphs |
rootMorphs _ self world rootMorphsAt: evt hand targetOffset.
target := OrderedCollection new.
rootMorphs size > 1
ifTrue: [target addLast: (rootMorphs at: 2)]
ifFalse: [^ self].
! !
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic