2014-12-17
Changing Attributes in Self objects
A question came up in the Self irc channel today about how to change the 'comment' string for an object. Comments are stored as attributes on an object. These are accessed using mirrors.
A mirror for an object can be obtained using the asMirror
method. The trait traits mirrors abstractMirror
provides a number of methods that can be used to change the object via the mirror. This involves everything that is normally done through the programming environment. It includes adding, removing and changing slots, categories, attributes amongst other things. By drilling down in this trait you can see a programming
category, which expands to include a changing annotation
category and that holds a comments
category. Within that you can find the methods for setting comments.
The video below shows the steps to find this from within the programming environment and demonstrates changing the comment on the initial shell
object on the desktop. The code to change that comment is just:
self asMirror comment: 'hello world'