Scilab Function
Last update : 25/03/2005

seteventhandler - set an event handler for the current graphic window

### Calling Sequence

  `seteventhandler(sfun_name)`
  `seteventhandler('')`

### Parameters

- `sfun_name`: a character string. The name of the Scilab function which is intended to handle the events

### Description

The function allows the user to set a particular event handler for the current graphic window. `seteventhandler('')` removes the handler.

The event handler is defined by a Scilab function whose calling sequence must be `function sfun_name(win,x,y,ibut)`, where

  `win` represents the number of the window where the event had occured.

  `x,y` are the coordinates of the pointer (in pixels), when the event has occured

  `ibut`is the event type:

  - ibut==0: Left mouse button has been pressed
  - ibut==1: Middle mouse button has been pressed
  - ibut==2: Right mouse button has been pressed

  - ibut==3: Left mouse button has been clicked
  - ibut==4: Middle mouse button has been clicked
  - ibut==5: Right mouse button has been clicked

  - ibut==10: Left mouse button has been double-clicked
  - ibut==11: Middle mouse button has been double-clicked
  - ibut==12: Right mouse button has been double-clicked

  - ibut==-5: Left mouse button has been released
  - ibut==-4: Middle mouse button has been released
  - ibut==-3: Right mouse button has been released

  - ibut==-1: pointer has moved

  - ibut > =32: key with ascii code ascii(ibut) has been pressed
  - ibut < =-32: key with ascii code ascii(-ibut) has been released

  - ibut > =1000+32: key with ascii code ascii(ibut-1000) has been pressed while CTRL key pressed
  - ibut==-1000: graphic window has been closed

### Examples

       function my_eventhandler(win,x,y,ibut)
          if ibut==-1000 then return,end
          [x,y]=xchange(x,y,'i2f')
           xinfo(msprintf('Event code %d at mouse position is (%f,%f)',ibut,x,y))
       endfunction
       plot2d()
       seteventhandler('my_eventhandler')
       //now:
       //   -  move the mouse over the graphic window
       //   -  press and release keys shifted or not with Ctrl pressed or not
       //   -  press button, wait a little release
       //   -  press and release button
       //   -  double-click button

       seteventhandler('') //suppress the event handler

### See Also

`addmenu`, `xgetmouse`, `xclick`, `xchange`,