event handler functions — Prototype of functions which may be used as event handler.
envent_handler_function(win,x,y,ibut)
window number where the event had occured.
X coordinate in pixels of the mouse pointer when the events occured.
Y coordinate in pixels of the mouse pointer when the events occured.
number corresponding to the event type.
When the event handler mode is enable, Scilab will call the specified event handler function each time an event occures in the graphic window. The event handler function must comply with the above prototype. Each time an event occured, the function is called and its four parameters are set accordingly to the window number, mouse position and type of event.
The ibut
parameter takes one of the following value depending on event type:
Left mouse button has been pressed
Middle mouse button has been pressed
Right mouse button has been pressed
Left mouse button has been clicked
Middle mouse button has been clicked
Right mouse button has been clicked
Left mouse button has been double-clicked
Middle mouse button has been double-clicked
Right mouse button has been double-clicked
Left mouse button has been released
Middle mouse button has been released
Right mouse button has been released
mouse pointer has moved
key with ascii code ascii(ibut) has been pressed
key with ascii code ascii(-ibut) has been released
key with ascii code ascii(ibut-1000) has been pressed while CTRL key pressed
graphic window has been closed
For example, let say that the name of the event handler function is fooHandler for window number 0. A left click in the window at position [100,150] (in pixels) will be equivalent as calling fooHandler( 0, 100, 150, 3 ).
See figure_properties or seteventhandler for information on how to specify the event_handler name.
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() fig = gcf() ; fig.event_handler = 'my_eventhandler' ; fig.event_handler_enable = "on" ; //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 fig.event_handler_enable = "off" ; //suppress the event handler