onclick = ...
This field allows you to specify a procedure to handle the event where the user clicks the markup element using the default mouse button.
An event field like onclick defines a procedure to be run when the event happens.
A procedure in ioL is simply a list of tags and data elements, which are evaluated (in order) to produce some result and/or behaviour. You can't create markup elements inside the event handling procedure itself, but you can use a push operation inside your procedure to add new markup elements to another location.
Example
In this example, we assign an event handler to a button that sends to lines of text back to the running program's input, and also makes the text on the button bold.
<abutton:button bold=false {I am a button} onclick= <putln {An event happened!}>, <putln {It's an onclick event!}>, <bold true> >
Modifying an existing event field
If you want to add instructions to an event field later, or clear the existing behaviour and define new behaviour, you need to use a push instruction rather than setting assigning the new code directly. This ensures that the code you assign isn't evaluated before it is set.
Suppose we want to modify the existing event handler by changing the onclick field. This doesn't do what we want:
<abutton.onclick <putln {An event happened and I don't care}>> <!INCORRECT!>
It doesn't work because of ioL's assignment precedence: ioL first tries to evaluate the putln tag to get a return value out of it, and then tries to assign the result of the evaluation. This means the putln instruction is executed immediately instead of stored in the event handler. It does not return a result, so nothing is stored in the onclick field.
Instead, we need to use a push operation. This assigns first and evaluates the code later in the context of the target field, which is what we want:
<abutton.onclick.clear> <abutton.onclick.push <putln {An event happened and I don't care}>>
The push operation doesn't clear the old field content for us, so we needed to clear the field first.