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

If you find an issue in LiveCode but are having difficulty pinning down a reliable recipe or want to sanity-check your findings with others, this is the place.

Please have one thread per issue, and try to summarize the issue concisely in the thread title so others can find related issues here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

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

Post by [-hh] » Mon Jun 06, 2016 1:24 pm

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.
Last edited by [-hh] on Mon Jun 06, 2016 2:39 pm, edited 1 time in total.
shiftLock happens

livecodeali
Livecode Staff Member
Livecode Staff Member
Posts: 171
Joined: Thu Apr 18, 2013 2:48 pm

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

Post by livecodeali » Mon Jun 06, 2016 2:11 pm

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'.

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

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

Post by [-hh] » Mon Jun 06, 2016 2:38 pm

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.
shiftLock happens

livecodeali
Livecode Staff Member
Livecode Staff Member
Posts: 171
Joined: Thu Apr 18, 2013 2:48 pm

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

Post by livecodeali » Mon Jun 06, 2016 3:06 pm

I've submitted a bug report for the missing documentation.
http://quality.livecode.com/show_bug.cgi?id=17799

Post Reply

Return to “Bug Triage”