YOU ARE VIEWING ARCHIVAL DOCUMENTATION FOR ioL VERSIONS 0.9x. Go to doc.iol.science for the latest version.
ioL

Programming manual (doc0.iol.science)



onmouseup = ...

This field allows you to specify a procedure to handle the event where the user releases a mouse button while the mouse pointer is inside the boundary of this markup element.

If this field is set, ioL will also respond to the event by providing mouse status information in the mouse field.


An event field like onmouseup 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} onmouseup=
  <putln {An event happened!}>,
  <putln {It's an onmouseup 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 onmouseup field. This doesn't do what we want:

<abutton.onmouseup <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 onmouseup 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.onmouseup.clear>
<abutton.onmouseup.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.