[Q] Making a button immune to mouse clicks

Ned Konz ned at bike-nomad.com
Sun Apr 14 14:23:20 UTC 2002


On Sunday 14 April 2002 07:08 am, I wrote:

> Any plain Morph (one that doesn't override handlesMouseDown: and
> mouseDown: et. al.) can be sensitized to mouse clicks. Just say:
>
> myMorph on: #mouseDown send: #doSomething to: someObject.

Just to clarify:

The #doSomething selector can actually have an arity (number of 
arguments) of 0, 1, 2, or 3. So you can pass the event itself, the 
morph that received the event, and a single parameter. But there is 
only one parameter shared between all the event types. To pass a 
parameter you use the form #on:send:to:withValue: .

These are passed as:

	arity = 0 ifTrue:
		[^ recipient perform: selector].
	arity = 1 ifTrue:
		[^ recipient perform: selector with: event].
	arity = 2 ifTrue:
		[^ recipient perform: selector with: event with: sourceMorph].
	arity = 3 ifTrue:
		[^ recipient perform: selector with: valueParameter with: event 
with: sourceMorph].

Unfortunately, the error message in 
EventHandler>>on:send:to:withValue: that says 'Warning: value 
parameters are passed as last of 3 arguments' is incorrect, as is the 
class comment in EventHandler which says it's:
	mouseDownRecipient perform: mouseDownSelector3 with: event with: 
targetMorph with: valueParameter

This is to keep you on your toes.
-- 
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE




More information about the Squeak-dev mailing list