Page 1 of 1

send mouseup to control

Posted: Wed May 24, 2017 6:12 pm
by capellan
Hi All,

Reading LiveCode Dictionary about the target and send,
could not find an obvious way to get the name of a message
sender without putting first this name in another container
(a custom property, a field or a global variable).

Why do I need to know which control send a message
to another control?

Because the handler in the control executes different code
depending of which control sends it a mouseup handler.

For now, I am using a mouseup button parameter that
could be 1 or 2 or 3. If the control receive a mouseup with
parameter 1, then executes handler 1. If the mouseup is
received with a parameter 2 then control executes
handler 2.

Which other ways could I use to produce the same result?

Al

Re: send mouseup to control

Posted: Wed May 24, 2017 6:52 pm
by richmond62
wdi.png
customProps
Who Did It.livecode.zip
Here's the stack.
(19.67 KiB) Downloaded 290 times
Click on all 3 buttons and the picture to see what messages you get :)

Re: send mouseup to control

Posted: Wed May 24, 2017 7:31 pm
by FourthWorld
The executionContexts is a good way to get any part of the calling chain. For the item in question, try:

Code: Select all

function CallerID
   -- Line -1 = this function
   -- Line -2 = the script that called this function
   -- so:
   return item 1 of line -3 of the executionContexts
end CallerID

Re: send mouseup to control

Posted: Thu May 25, 2017 6:47 pm
by jacque
I generally just use "the name of the target" or "the short name of the target", depending on whether I need the object identifier included.

Re: send mouseup to control

Posted: Thu May 25, 2017 7:46 pm
by FourthWorld
Doesn't the target change with "send"?

Re: send mouseup to control

Posted: Thu May 25, 2017 8:07 pm
by jacque
FourthWorld wrote:Doesn't the target change with "send"?
Yes, I missed that part. I read the OP as considering the two terms separately rather than in tandem.