Handling one MC message blocks another

depstein at att.net depstein at att.net
Mon Dec 27 17:18:26 EST 2004


Dave Cragg wrote:
>  I don't think the engine takes those kinds of "smart" decisions. What 
> you're seeing may be explained by the focus shifting to the message box 
> during the mouseDown handler. I think this is what interferes with the 
> linkClicked being handled. Try this instead, which dosn't move focus 
> out of the field:
> 
> global gTemp
> 
> on linkClicked
>    put "c" & cr after gTemp
> end linkClicked
> 
> on mouseDown
>    put empty into gTemp
>    if the lockText of me then
>      put "a" & cr after gTemp
>    else
>      put "b" & cr after gTemp
>    end if
> end mouseDown
> 
> And in a separate button on the same card put this:
> 
> on mouseUp
>    global gTemp
>    put gTemp
> end mouseUp
> 
> After command-clicking the link, and then clicking the new button, I 
> think you'll see that the mouseDown and linkClicked messages are in 
> fact handled.

Thanks to Dave Cragg for his revision of my test to determine the interaction of "mousedown" and "linkclicked."  I can replicate his results, but I don't quite understand his explanation.  Why should putting something in the message box change the focus, since I'm not setting an insertion point.  And runnng this script from a button:

put "hello"
put the focusedObject after msg

does not indicate that the message box becomes the focusedObject.

So I don't any longer have a general rule to offer, but here's my evidence, which I hope someone can explain and turn into a rule:

With handlers for mouseDown, linkClicked, and mouseUp in an unlocked field with some text whose style is link, command click on that linked text.  Each handler appends a character (d,c, and u, respectively) to a global variable, whose value is inspected after the fact (as Dave Cragg suggested).  Results:

-- the mouseDown message is always received.
-- with all 3 handlers doing nothing but appending to the global variable, the linkClick message is received but the mouseup message is not received (global variable's ending value is "dc")
-- if I comment out or erase the linkclicked message, the mouseup message is received ("du")
-- if I add some other commands to my mouseDown handler, the content of those commands determines whether the linkClicked or the mouseUp message is received (it's one or the other, not both):
	* on mouseDown, put a value in the message box:  no linkClicked message ("du")
	* on mouseDown, write a value to a field:  no linkClicked message ("du")
	* on mouseDown, writing to a variable or setting a custom property or setting a backColor does not block the linkClicked message ("dc")

So we seem always to get EITHER the linkclicked or the mouseup message, but which one we get depends on what the mouseDown handler does.  Explanations welcomed.

David Epstein



More information about the metacard mailing list