target

returns the object which received the message that started execute.

# Metadata

Platforms: desktop, server, mobile OS: mac, windows, linux, ios, android Introduced: 1.0 Security:

# Syntax

the target

# Examples

the target

if word 1 of the target is "button" then clickedAButton

set the backgroundColor of the target to "black"

# Description

Use the target function within a message handler to determine which object originally received the message.

Suppose a card script contains a mouseDown handler. If the user clicks a button, a mouseDown message is sent to the button. If the button script does not contain a mouseDown handler, the message is pass to the card, and handle by the card mouseDown handler.

The target function is similar to the me keyword. In the example described above, within the card handler, the target function returns the button name, because the button is the object that first received the mouseDown message. However, the me keyword is a object reference to the card, because the card is the object whose script contains the mouseDown handler that is execute.

# Tags

# See

- **property:** script, name, text - **message:** mouseDown - **keyword:** me, target, button - **object:** card, button - **function:** dragSource, dragDestination, selectedObject - **glossary:** return, property, handle, handler, execute, pass, message, card, keyword, object reference, object - **control structure:** function