Target and Me
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Target and Me
I have a confession, I have never really understood the difference between Target and Me in LiveCode. I can imagine most of your reactions will be, “Oh My God, you gotta be kidding me, this guy should have learned this stuff in LiveCode 101”. I’m self taught in LiveCode and I have never really grasped the difference between the two. That’s why I’m asking for help from someone to direct me to a PLAIN LANGUAGE description or EXAMPLE that clearly illustrates the differences. To that someone, I thank you in advance. And, yes, I have read and re-read the dictionary and Devin Asay’s comments about them on his BYU website. Both are written in a way that hasn’t yet helped me “get it.”
urbaud
Re: Target and Me
Hi,
I dont use "me" but your post help me to grow up about it
Try this.
One cd with a btn.
Put this script into the cd script:
You get this result:
the target =button "Button"
me =card id 1002
Best regards
Jean-Marc
I dont use "me" but your post help me to grow up about it
Try this.
One cd with a btn.
Put this script into the cd script:
Code: Select all
on mouseup
put "the target =" & the target & cr & "me =" & me into fld "fResult"
end mouseup
the target =button "Button"
me =card id 1002
Best regards
Jean-Marc
https://alternatic.ch
Re: Target and Me
Hi Dan,
lets make an experiment.
you make a card with some controls on it that respond to clicks. You do not want to script every control individually but you want to have one script at the card level that branches depending on which control was clicke on. Here you ask for the target.
The Target is the control that receives the mouse click and gets a mouseUp message after clicking. Since the controls do not have a script the mouseUp message go up the message path and the card is the next place where the mouseUp message passes. Here you trap the message with a
on mouseUp handler.
Me is the control/place where the currently running script is placed.
In above example where the "mouseUp" handler lives in the card script any "me" refers to the card.
see attached stack
and please don't think this is 101, I guess many from 201 would not know the difference
Kind regards
Bernd
lets make an experiment.
you make a card with some controls on it that respond to clicks. You do not want to script every control individually but you want to have one script at the card level that branches depending on which control was clicke on. Here you ask for the target.
The Target is the control that receives the mouse click and gets a mouseUp message after clicking. Since the controls do not have a script the mouseUp message go up the message path and the card is the next place where the mouseUp message passes. Here you trap the message with a
on mouseUp handler.
Me is the control/place where the currently running script is placed.
In above example where the "mouseUp" handler lives in the card script any "me" refers to the card.
see attached stack
and please don't think this is 101, I guess many from 201 would not know the difference

Kind regards
Bernd
- Attachments
-
- TargetAndMeDanUrbaud.livecode.zip
- (1.22 KiB) Downloaded 282 times
Re: Target and Me
What everyone said. Here is another experiment. On a new card place three fields. Name them differently. Put different text into each. Now lock all three. In each field place this script:
Now click on each field in turn. The target is the field name, "me" returns the field contents.
The target is probably most useful when used in Bernd's example, to oversee a large group of controls with a single handler placed at a higher level. "Me" is the contents of that control, usually a field or button, but must be accessed at the control level. That is why I responded, to show the difference from his example where me is the card.
You can put data into "me". Try it. Can you write a script that does this with those locked fields?
Craig Newman
Code: Select all
on mouseUp
put the short name of the target & return & me
end mouseup
The target is probably most useful when used in Bernd's example, to oversee a large group of controls with a single handler placed at a higher level. "Me" is the contents of that control, usually a field or button, but must be accessed at the control level. That is why I responded, to show the difference from his example where me is the card.
You can put data into "me". Try it. Can you write a script that does this with those locked fields?
Craig Newman
Last edited by dunbarx on Wed Jan 22, 2014 4:30 pm, edited 2 times in total.
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Target and Me
Don't feel bad. It was a mind-bender for me when I got started, and for many others I know.urbaud wrote:I have a confession, I have never really understood the difference between Target and Me in LiveCode. I can imagine most of your reactions will be, “Oh My God, you gotta be kidding me, this guy should have learned this stuff in LiveCode 101”. I’m self taught in LiveCode and I have never really grasped the difference between the two.
This description helped me:
"The target" is the thing that received the message.
"Me" is the thing that contains the script being executed as a result of that message.
When you have a mouseUp handler in a button, the button is both "the target" and "me".
But if you handle mouseUp in the card script, when you click on the button, the button is "the target" and "me" is the card.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Target and Me
One caveat about "target". I see lots of people here who omit the word "the" before property names, that is, instead of using "the date" they will script only "date". This may bite you sometimes, and "target" is one of those times. LiveCode is forgiving in parsing its syntax, but if it ever starts enforcing the rules all existing scripts that omit "the" will break.
In the case of "target" your scripts will already break if you omit "the", because "the target" and "target" are two different things. This is due to compatibility with HyperCard, but it's also very useful in some situations. "The target" refers to an object, the one that received the message. "Target" (alone, without "the") refers to the text of a field.
In other words:
"put target" = "put the text of the target"
One of my pet peeves is the omission of "the", but I know some people do it to make a distinction between properties and functions. In this case, you can't.
In the case of "target" your scripts will already break if you omit "the", because "the target" and "target" are two different things. This is due to compatibility with HyperCard, but it's also very useful in some situations. "The target" refers to an object, the one that received the message. "Target" (alone, without "the") refers to the text of a field.
In other words:
"put target" = "put the text of the target"
One of my pet peeves is the omission of "the", but I know some people do it to make a distinction between properties and functions. In this case, you can't.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Livecode Opensource Backer
Re: Target and Me
I want to thank all of you who responded to my post. Your comments and examples were very helpful to me, in fact, I think I "got it" regarding Target and Me. So, again, thanks for your help.
Dan
Dan