Livecode Wiki

A Message sent to an object(glossary) when its name is changed. If there is a message handler by the same name in the message path, then it will be executed.



nameChanged <oldName>, <newName>

The parameter <oldName> is the object's original name. The parameter <newName> is the object's new name.

Message handler[]


on nameChanged myOldName,myNewName -- replace name in a menu button
  put lineOffset(myOldName,button "Window List") into namePosition
  put myNewName into line namePosition of button "Window List"
end nameChanged

Use the nameChanged Message handler if you want to make updates when an object's name is changed. For example, if you have a popup menu with the names of stacks, the menu should be updated when a stack's name changes.

The actual change is not triggered by the nameChanged message, so trapping the message and not allowing it to pass does not prevent the name from being changed.

See also: IDChanged, stack, showName, groupNames, cardNames, name & number.