4. Events

4 Events

4.1 Event Messages

Events are messages which are sent to the owner process of the object when the user interacts with the object in some way. A simple case is the user pressing a button. An event is then delivered to the owner process of the button (the process that created the button). In the following example, the program creates a button object and enables the events click and enter. This example shows that events are enabled in the same way as objects are configured with options.

B = gs:create(button,Win, [{click,true},{enter,true}]),
event_loop(B).
    

The process is now ready to receive click and enter events from the button. The events delivered are always five tuples and consist of:

{gs, IdOrName, EventType, Data, Args}