Page 1 of 1

[Solved] Wrong logic of the target (for events)?

Posted: Mon Jun 06, 2016 1:24 pm
by [-hh]
There seems to exist a "wrong" logic for "the target" (for events only?).

Script a button "ONE" with

Code: Select all

on mouseUp
  answer "ONE: " & (the long id of the target = the long id of me)
end mouseUp
Script a button "TWO" with

Code: Select all

on mouseUp
  send "mouseUp" to btn "ONE"; pass mouseUp
end mouseUp
Script the card with

Code: Select all

on mouseUp
  answer "CARD: " & (the long id of the target = the long id of me)
end mouseUp
Click on button "TWO". You'll get
  • "ONE: true" (from button "ONE") -- I would expect "false" here!?
  • "CARD: false" (from the card) -- as expected.
Tested on LC 6.7.11/7.1.4/8.1.0-dp1. All show the same behaviour as described above.

Re: Wrong logic of the target (for events)?

Posted: Mon Jun 06, 2016 2:11 pm
by livecodeali
This is because you have synthesised the 'mouseUp' message with the 'send' command - 'the target' is changed by the 'send' and 'dispatch' commands to their target while they are executing.
I do think that information is missing from the dictionary entries of both 'send' and 'dispatch' though.

You can use the 'call' command to do the same thing without affecting 'the target'.

Re: Wrong logic of the target (for events)?

Posted: Mon Jun 06, 2016 2:38 pm
by [-hh]
Ali wrote:You can use the 'call' command to do the same thing without affecting 'the target'.
Thanks, new insight for me: "call" preserves the target, not "send", not "dispatch".
I'll change all my scripts, one after the other. This explains immediately a lot of issues I "worked around" until now, for example by checking the clickLoc.
Ali wrote:I do think that information is missing from the dictionary entries of both 'send' and 'dispatch' though.
Yes, and this information from "call" could also go to "the target"-entry:
"This [not changing context of 'call'] differs from the send command which temporarily changes the context so that object references are evaluated in the context of the object containing the target handler."

Good thing, this "bug triage"-subforum.

Re: [Solved] Wrong logic of the target (for events)?

Posted: Mon Jun 06, 2016 3:06 pm
by livecodeali
I've submitted a bug report for the missing documentation.
http://quality.livecode.com/show_bug.cgi?id=17799