[comp.sys.mac.hypercard] freezing or disabling buttons

lampert@yale.UUCP (Robin Lampert) (06/16/88)

I'm working on a hypercard stack.  It has (background) buttons which pop
up (background) fields, and then clicking on the field makes it go away.
Unfortunately, there are also some transparent card buttons which
connect to other cards which overlap with the fields.  So, when the user
clicks on the field in a spot which happens to also have one of these
transparent buttons there, the user ends up on a different card, instead
of simply getting rid of the field.  I'd like to fix it so that this
doesn't happen.

I'd like to be able to freeze/unfreeze all the card buttons (but not the
background buttons) in a single command or very short sequence.
(Disabling all the card buttons one at a time in a loop takes too much
time.)

Does anyone know how to do this?  or have any other possibly useful
suggestions?

-- 
-Robin Lampert

lampert@cs.yale.edu

pem@cadnetix.COM (Paul Meyer) (06/18/88)

[]
Suggestion 1:
	Make the link buttons' scripts check for the popped-openness
of the fields that should obscure them before doing their jumps:

on mouseup -- link unless obscured
    if not the visible of field xyzzy
	go to card 71077345
end mouseup

Suggestion 2:
	Have you thought about using a global Hypertalk variable, or a
hidden background field, to control the *buttons'* scripts?

	This would also simplify the logic for determining when to
disable the buttons, too:  (pardon any syntax problems--I don't do
Hypertalk that often.)

on mouseup -- pop up my field
    if the visible of field xyzzy then
	hide field xyzzy
	put field popcount - 1 into field popcount
    else
	show field xyzzy
	put field popcount + 1 into field popcount
    endif
end mouseup

on opencard -- on entering a card of this background, close all the ~
	       popups.
    hide field xyzzy
    hide field plugh
    hide field dwarf
    put 0 into field popcount
end opencard

on mouseup -- link if no fields popped up
    if field popcount < 1 go to card 71077345
end mouseup

Suggestion 2':
	Perhaps you want the link buttons to still be creatable by the
"create link" option.  In this case, you could follow method 2 but
patch the "go" command at the background level.  (This is where my
lack of recent hyperhacking shows badly, but a few minutes with the
manuals should make this work.)  Leave the opencard and popup-button
handlers alone, but put this in the background script:

on go alfa bravo charlie delta echo foxtrot golf hotel
    if (alfa = "to") and (bravo = "card") and (charlie = "id") -- or ~
		some such nonsense--check a "create link"'ed button ~
		for what the syntax it uses is
	if field popcount < 1 go to card id delta
    else
	pass go alfa bravo charlie delta echo foxtrot golf hotel --collect $200
    endif
end go

Summary:  instead of manipulating all the buttons, make their behavior
match what you want them to do--that's the power of scripting!

Paul Meyer                      pem@cadnetix.COM
Cadnetix Corp.
5775 Central Ave.               {uunet,boulder}!cadnetix!pem
Boulder, CO 80301               (303)444-8075x244

pem@cadnetix.COM (Paul Meyer) (06/18/88)

[]
	Oops--I did all those examples assuming that you wanted the
button clicked again to hide the field, but that change is pretty
trivial...

Paul Meyer                      pem@cadnetix.COM
Cadnetix Corp.
5775 Central Ave.               {uunet,boulder}!cadnetix!pem
Boulder, CO 80301               (303)444-8075x244