Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Mouse button tester
Last updated at 7:26 pm UTC on 7 June 2018

2017

Open a Workspace and paste the following code snippet into it (works in Squeak 5.2a as it has the update of June 2017 included, see below)

Select all and choose 'do-it'.

 m := Morph new.
 m extent: 80@80.
 m wantsHaloFromClick: false.
 m wantsYellowButtonMenu: false.
 m wantsMetaMenu: false.
 m balloonText: 'Click any button outside center box to change color to color of button clicked. Click red button in center box to dismiss'.

 pbm:= PluggableButtonMorph on: m getState: #isMorph action: #dismissMorph.

 m on: #mouseDown send: #value: to:[:evt|
         evt redButtonPressed ifTrue:[m color: Color red].
         evt yellowButtonPressed ifTrue:[m color: Color yellow].
         evt blueButtonPressed ifTrue:[m color: Color blue] ].

 m addMorphCentered: pbm.
 m openInHand.


You get a rectangle which changes color according to the mouse button clicked. This may help you setting up the right mouse configuration.
The June 2017 update fixes the problem mentioned below (March 2002).


See also

SensorReporter
MousePositionInfoMorph
Reasons for referring to the mouse buttons by a color


The original version below (2002) of this code left a zombie morph in the playfield of the current world. This 2017 version adds a dismiss button.


Andreas Raab, March 2002


For the blue button this did not work properly, since the Morph in question insists on bringing up the halo instead of changing color on a blue button click.

Morph>>blueButtonDown: catches the blue button and brings up a halo first.

If you want to see the events, you can just do this:
    HandMorph showEvents: true

and when you're done you can do this:
    HandMorph showEvents: false


Update June 2017

Squeak 6.0a trunk
[squeak-dev] The Trunk: Morphic-mt.1342.mcz
   Squeak 
Add star 
commits@source.squeak.org
<commits@source.squeak.org>	Fri, Jun 30, 2017 at 9:26 AM
Reply-To: squeak-dev@lists.squeakfoundation.org
To: squeak-dev@lists.squeakfoundation.org, packages@lists.squeakfoundation.org
Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1342.mcz

==================== Summary ====================

Name: Morphic-mt.1342
Author: mt
Time: 30 June 2017, 9:26:09.827527 am
UUID: 42b6a5ae-42d0-9849-ac5e-5950b96e6e55
Ancestors: Morphic-nice.1341


 Extract initial invocation of halo or meta menu to event filter at world level. Having this, EventHandler is more reliable 
 and invocation logic is fully captured in PasteUpMorph >> #tryInvokeHalo:. 
 Further halo transfer logic enclosed in SimpleHaloMorph.
This works now:

m := Morph new.
m openInWorld.

m wantsHaloFromClick: false.
m wantsYellowButtonMenu: false.
m wantsMetaMenu: false.

m on: #mouseDown send: #value: to:[:evt|
        evt redButtonPressed ifTrue:[m color: Color red].
        evt yellowButtonPressed ifTrue:[m color: Color yellow].
        evt blueButtonPressed ifTrue:[m color: Color blue]].

=============== Diff against Morphic-nice.1341 ===============



tagBeginner