[Q] Making a button immune to mouse clicks

Andreas Raab Andreas.Raab at gmx.de
Sun Apr 14 14:31:25 UTC 2002


Martin,

> I want the Button to be event-wise a lot bigger than the visible
> Button. I want a large Rectangle with a small Button in it. In the
> remaining space in the Rectangle I want to put other things, but I
> want to be able to drag the whole thing around with the button.

I am completely confused by your description. You say you want "the
Button to be event-wise a lot bigger than the visible Button" which to
me means you want the button to be a button (e.g., clickable). But then
you say you want to "drag the whole thing around". So do you want to
make a button (e.g., an object that performs an action upon click) or
not? Or is it just that you want to have a morph that _looks_ like one
of the button classes (e.g., like SimpleButtonMorph)? In this case you
can construct your own pretty easily, e.g., something like:

m _ RectangleMorph new.
m borderWidth: 1.
m cornerStyle: #rounded.
m color: (Color r: 0.4 g: 0.8 b: 0.6).
m borderColor: m color darker.
label _ StringMorph new contents: 'Flash'.
m extent: label extent + m borderWidth + 6.
m addMorphCentered: label.
m openInWorld.

will give you something that looks exactly like a SimpleButtonMorph.

> How can I possibly drag a button without invoking the mouse action?

You don't. A button is an object that has an action to perform on a
click. Unless of course ... you do something like:

m := SimpleButtonMorph new.
m on: #mouseDown send: #grabMorph: to: m.
m openInWorld.

(which is kinda pointless but hey).

Cheers,
  - Andreas




More information about the Squeak-dev mailing list