[comp.sys.mac.hypercard] click at ... with <modifier key> problems

mrs2@bunny.gte.com (Mark Scherfling) (05/03/91)

Ok, this has got to be a well known bug-a-boo, but I'm lost.
I have a script which reads:
   click at the loc of cd btn test with optionKey

And within cd btn test I have the handler:
   on mouseUp
      if the optionKey is down then ....

But the logic *never* executes.  When I manually click in the button with 
the optionKey, it works fine.  This happens with any modifier key used.  
All the documentation and manuals I can find read as if this is a 
perfectly valid operation to do.  What gives?  This problem exists in HC 
1.2.5 and 2.0v2.  Any help here would be greatly appreciated.
Thanks.

-- Mark Scherfling
   mrs2@gte.com

al@crucible.UUCP (Al Evans) (05/04/91)

In article <11126@bunny.GTE.COM> mrs2@bunny.gte.com (Mark Scherfling) writes:

>Ok, this has got to be a well known bug-a-boo, but I'm lost.
>I have a script which reads:
>   click at the loc of cd btn test with optionKey
>
>And within cd btn test I have the handler:
>   on mouseUp
>      if the optionKey is down then ....
>
>But the logic *never* executes.  When I manually click in the button with 
>the optionKey, it works fine.

This is documented in _HyperCard 2.0: The Book_ (p. 186):

"Click not an exact substitute for manual clicking: You can't use the click
command to simulate manual shortcuts. Thus you can't use

click at 200,200 with optionkey, commandkey

to bring up the [optionkey or commandkey, presumably -me] handler of the 
button at 200,200. (HyperCard needs to see the actual keys go down before 
it allows such shortcuts.)"

Granted that this is not particularly clear, but it seems to imply that
the behavior you're seeing is a, uh, "feature".

					--Al Evans--
-- 

Al Evans                                                Reality is like this:
al@crucible.uucp                                          We are born knowing
uunet!execu!sequoia!crucible!al                 the world isn't what we think.

kevin@umbc4.umbc.edu (Kevin Hunter Services) (05/05/91)

In article <11126@bunny.GTE.COM> mrs2@bunny.gte.com (Mark Scherfling) writes:

>Ok, this has got to be a well known bug-a-boo, but I'm lost.
Type h for help.
>I have a script which reads:
>   click at the loc of cd btn test with optionKey
>
>And within cd btn test I have the handler:
>   on mouseUp
>      if the optionKey is down then ....
>
>But the logic never executes.  When I manually click in the button with 
>the optionKey, it works fine.

I use a simple workaround for this in the button script:

on mouseUp flag
  if flag is empty then put (the optionKey is "Down") into flag
  if flag is true then
    ...
  else
    ...
  end if
end mouseUp

Now send a mouseup to the button with a "true" flag:

  send mouseup && "true" to card button "Try Me"

Normal mouseUps will send only empty parameters and take that as a clue
to go look up what's going on with the optionkey.

I rarely use the "click at..." command if I can help it. Globals could 
be used for flags in such scripts but they can get very complex and 
unpleasant to work with. Hope this helps.

Kevin Hunter


-- 
Oh... I see...
      another pile of mindless drivel.
      internet:kevin@umbc4.umbc.edu (Kevin Hunter)
      

ech@cbnewsk.att.com (ned.horvath) (05/06/91)

In article <11126@bunny.GTE.COM> mrs2@bunny.gte.com (Mark Scherfling) writes:
 
>Ok, this has got to be a well known bug-a-boo, but I'm lost.

>I have a script which reads:
>   click at the loc of cd btn test with optionKey

>And within cd btn test I have the handler:
>   on mouseUp
>      if the optionKey is down then ....
>
>But the logic never executes.  When I manually click in the button with 
>the optionKey, it works fine.

You might separate the operation from the way it's invoked:

on mouseUp
	if optionKey then doTheOptionThing
	else
		...
	end if
end mouseUp

on doTheOptionThing
	...
end doTheOptionThing

Now you can "send doTheOptionThing to theButton" from anywhere.  Naturally
you'll choose a more meaningful name than 'doTheOptionThing,' unless you're
George Bush...

=Ned Horvath=
ehorvath@attmail.com
-- 

=Ned Horvath=
ehorvath@attmail.com