Button Event!!!!

Stefan Krecher stefan at krecher.de
Tue Aug 23 15:14:07 UTC 2005


Hi,

On Tue, Aug 23, 2005 at 03:44:04PM +0200, EL Marjani Radouane wrote:
> I will first writte my Code:
[...]
> HandyButton>>mouseDown: evt 
> new HandyDesign displayChange

you should in "mouseDown:" fetch an instance of "HandyDesign" - looks
like you've been programming in Java for too long ;-)
P.e. if you implemented a Singleton it would look something like that:
HandyDesign instance displayChange.

> I want to click on Button(HButton), and
> Display will must change: take a new Picture!!!But es
> geht wrong!!!!!!!!Help!!!!!!!!!!!!!!!!!"

I did something similar: i needed a Button which changend the image
while beeing pressed, sources are attached, maybe it's usefull for
you.
You will need to import images into the ImagesImports-Dict (you can do
that via the file-list-dialog) an can test it as follows:

(SwitchImageMorph new initialize: #('img_off' 'img_on') actionClass:
AbstractAction) openInWorld.

img_off/on are the names of the Images as they appear in ImageImports,
the action-class implements the desired action to execute when the
button was pressed.

Don't know if this is the best way to solve such a problem or if the
design is squeakish - but it works ...

regards,
Stefan

-- 
GPG fingerprint = 2E77 C256 47B1 27B8 AE07  94BE D7A1 2A3C C716 2BE9
GPG public key: http://krecher.de/pubkey.asc           ICQ #84067348
  "A specter ist haunting the modern world, the specter of crypto 
     anarchy"    The Crypto Anarchist Manifesto, Timothy C. May
-------------- next part --------------
'From Squeak3.8 of ''5 May 2005'' [latest update: #6665] on 23 August 2005 at 4:43 pm'!
Object subclass: #AbstractAction
	instanceVariableNames: 'value'
	classVariableNames: 'Value'
	poolDictionaries: ''
	category: 'HomeMedia-Actions'!

!AbstractAction methodsFor: 'as yet unclassified' stamp: 'smk 3/8/2005 09:34'!
action
Transcript show: 'action not implemented'; cr.! !

!AbstractAction methodsFor: 'as yet unclassified' stamp: 'smk 3/11/2005 08:17'!
cleanup
Transcript show: 'no cleanup-action implemented'; cr.! !

!AbstractAction methodsFor: 'as yet unclassified' stamp: 'smk 3/8/2005 09:51'!
exec
Transcript show: 'Action class: ', self class asString, ', value: ', value asString; cr.
self action.! !

!AbstractAction methodsFor: 'as yet unclassified' stamp: 'smk 3/8/2005 09:46'!
exec: aValue
value _ aValue.
self exec
! !

!AbstractAction methodsFor: 'as yet unclassified' stamp: 'smk 8/3/2005 18:18'!
nextAction
Transcript show: 'nextAction not implemented'; cr.! !

!AbstractAction methodsFor: 'as yet unclassified' stamp: 'smk 8/3/2005 18:19'!
value
^value! !

!AbstractAction methodsFor: 'as yet unclassified' stamp: 'smk 8/3/2005 18:19'!
value: aValue
value _ aValue! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

AbstractAction class
	instanceVariableNames: ''!

!AbstractAction class methodsFor: 'as yet unclassified' stamp: 'smk 8/4/2005 15:33'!
value
^Value! !

!AbstractAction class methodsFor: 'as yet unclassified' stamp: 'smk 8/4/2005 15:33'!
value: aValue
Value _ aValue! !
-------------- next part --------------
'From Squeak3.8 of ''5 May 2005'' [latest update: #6665] on 23 August 2005 at 4:40:28 pm'!
ImageMorph subclass: #SwitchImageMorph
	instanceVariableNames: 'imageOn imageOff action id selected'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'HomeMedia-GUI'!

!SwitchImageMorph methodsFor: 'as yet unclassified' stamp: 'smk 2/24/2005 09:27'!
action
^ action! !

!SwitchImageMorph methodsFor: 'as yet unclassified' stamp: 'smk 2/24/2005 09:27'!
action: anAction
action _ anAction! !

!SwitchImageMorph methodsFor: 'as yet unclassified' stamp: 'smk 2/23/2005 17:09'!
handlesMouseDown: evt
^true! !

!SwitchImageMorph methodsFor: 'as yet unclassified' stamp: 'smk 3/8/2005 19:03'!
id
^id! !

!SwitchImageMorph methodsFor: 'as yet unclassified' stamp: 'smk 3/8/2005 19:03'!
id: anId
id _ anId! !

!SwitchImageMorph methodsFor: 'as yet unclassified' stamp: 'smk 3/11/2005 09:15'!
initialize: aColWithStrings actionClass: anActionClass

imageOn _ ImageImports at: (aColWithStrings at: 1).
imageOff _ ImageImports at: (aColWithStrings at: 2).
image _ imageOn.
selected _ false.
action _ anActionClass.! !

!SwitchImageMorph methodsFor: 'as yet unclassified' stamp: 'smk 3/17/2005 15:45'!
mouseDown: evt
self off.
EventHandling event: evt actionClass: self action.
^true! !

!SwitchImageMorph methodsFor: 'as yet unclassified' stamp: 'smk 3/11/2005 09:16'!
mouseUp: evt
selected ifFalse: [ self on ].

^true! !

!SwitchImageMorph methodsFor: 'as yet unclassified' stamp: 'smk 2/18/2005 19:09'!
off
 self image: imageOff! !

!SwitchImageMorph methodsFor: 'as yet unclassified' stamp: 'smk 2/18/2005 19:09'!
on
 self image: imageOn! !

!SwitchImageMorph methodsFor: 'as yet unclassified' stamp: 'smk 3/11/2005 09:17'!
setSelect: aBool
selected _ aBool.! !
-------------- next part --------------
'From Squeak3.8 of ''5 May 2005'' [latest update: #6665] on 23 August 2005 at 4:42:20 pm'!
Object subclass: #EventHandling
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'HomeMedia-Util'!

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

EventHandling class
	instanceVariableNames: ''!

!EventHandling class methodsFor: 'as yet unclassified' stamp: 'smk 2/24/2005 09:12'!
event: evt
evt inspect! !

!EventHandling class methodsFor: 'as yet unclassified' stamp: 'smk 3/17/2005 15:28'!
event: evt actionClass: anActionClass
anActionClass new exec: evt.! !


More information about the Squeak-dev mailing list