Tinderbox Forum

How to add OnAdd from the Help Tutorial

I’m slightly confused about the part of the ‘Getting Started’ tutorial where we add an action for the first time. The idea is that any new note added to the container should inherit from the “Story” prototype.

Should be entry in the Action panel be:

or just

Neither work for me. I definitely have the School Stories container selected when I open the inspector. I’ve tried various combinations of code but not been successful and can’t find an exact example to follow. I’m using TB version 6.6.5 by the way.

$OnAdd is an attribute. You can find in by adding it to the note’s displayed attributes or simply by typing ⌘2 and looking for it. Then you should add $Prototype="Story". Make sure to use straight quotes, by the way.

1 Like

I must be still doing something wrong because it isnt working.

My entry in the Actions panel (under the cog icon and Action tab):

Does OnAdd need a $ as well? Do I enclose the $Prototype part in parentheses?

OK I finally figured out what to do. Instead of putting the action in the Cmd+1 panel I had to add the attribute using the + button and then enter the $Prototype=“Story” in its value field. Thanks for your help.


In the Action pane of the action inspector, enter the OnAdd action: $Proptotype="Story".

Wow do we get syntax highlighting? :flushed:

Syntax colouring? Not yet, but soon in v9 (this has been shown during Tinderbox Saturday meet-ups).

OK, we want to set a note’s Prototype attribute to Story using the OnAdd action.

In the Action Inspector (as above), we type only the code needed to carry out the action:

$ Prototype = "Story";

Th4 same code would be used via QuickStamp. But, to set a the a container’s OnAdd action via code we need to enclose the above action in quotes. Why? Because the code for the action need to ve passed as a String to the target note’s OnAdd. So, to set OnAdd via a stamp:

$OnAdd = '$ Prototype = "Story";';

To make all the code into a string here, we neecd to use single quotes as the enclosed code already uses double quotes. The resulting OnAdd value of the stamped note(s) will be:

$ Prototype = "Story";

So for direct edit (Inspector , Quickstamp) you just set the code into the input box. In an action to set the OnAdd attribute value you need to pass the action’s code as a single string.

†. Unless of course your code used single quotes, in which case make the outer set double quotes.