Buttons in Morphic

Ned Konz ned at bike-nomad.com
Sat Apr 7 05:49:33 UTC 2001


On Friday 06 April 2001 22:11, Dan Shafer wrote:
> I've just spent several hours over the last two days delving into
> SimpleButtonMorph and trying to understand why buttons in Morphic don't
> behave the way I expected them to behave. If I have this right, it is
> completely unclear to me how buttons are _suppsoed_ to be used in Morphic.
>
> Here's what I _think_ I've learned.
>
> A SimpleButtonMorph appears to "eat" the usual mouse events: mouseDown,
> mouseUp, and mouseStillDown. It has a default "flash" behavior that it
> executes on mouseUp. Even though its halo menu has an item called "add
> mouseUp action," doing so seems to have no discernible effect. Neither, for
> that matter, does "remove mouseUp action." You can write a script for such
> a button, set it to active on mouseUp and you can click on that sucker
> until your hand breaks and nothing is going to happen. This despite the
> fact that when you click on the instant-execution yellow exclamation point
> in the script tile, the script runs exactly as expected every time.

I don't know how to use these in a Scripting sense.

It is unfortunate that they inherit the "add mouse up action" menu choice 
from BorderedMorph or wherever, since (I believe) that it doesn't work.

But they _do_ add three menu items that do make a difference:
change label/action selector/arguments/when to act.

Unfortunately, there isn't a really reliable way to change their target. So 
none of the above items would do any good, since the button does nothing 
without a target.

There is logic that looks for

	World rootMorphs at: aHandMorph targetOffset

to decide whether to add a "set target" menu choice. However, this logic is a 
wrong (I think) since targetOffset is the offset of the last mouse click 
relative to the button (which is not useful for finding prospective targets).

You can see this menu item by putting a large Morph in the upper left hand 
corner of the World and then getting the control menu. If you choose it, 
though, it'll not have the effect you want.

Probably more useful would be to allow selection of a target, perhaps by 
dropping a HandleMorph on it. Or just by looking underneath the button.

I have no idea what "hand me tiles to fire this button" does; it just 
appeared around CS 3894 and I've never tried it.

I always use them programmatically with target: because I haven't been able 
to get them to work from the menu (because of the lack of setTarget:).

-- 
Ned Konz
currently: Stanwood, WA
email:     ned at bike-nomad.com
homepage:  http://bike-nomad.com





More information about the Squeak-dev mailing list