YOU ARE VIEWING DOCUMENTATION FOR ioL v.1. Click here for documentation for older v.0.9x versions of ioL.
ioL

Programming manual (doc.iol.science)



onMouseIn = ...

This field allows you to specify a procedure to handle the event where the mouse pointer enters 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 onMouseIn 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} onMouseIn=
  <putLn {An event happened!}>,
  <putLn {It's an onMouseIn 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 onMouseIn field. This doesn't do what we want:

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