Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.0.1 - Русский

Change language to:
English - Français - 日本語 - Português -

Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
See the recommended documentation of this function

Справка Scilab >> Графики > interaction > event handler functions

event handler functions

Prototype of functions which may be used as event handler.

Syntax

event_handler_function(h,x,y,ibut)

Arguments

h

window number if the event occurred in an axe with a figure type parent. (DEPRECATED)

handle of the axe's parent where the event occurred.

x

X coordinate in pixels of the mouse pointer when the events occurred.

y

Y coordinate in pixels of the mouse pointer when the events occurred.

ibut

number corresponding to the event type.

Description

When the event handler mode is enable, Scilab will call the specified event handler function each time an event occurres in the graphic window. The event handler function must comply with the above prototype. Each time an event occurred, 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:

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

mouse 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

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.

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()
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

See also

  • figure_properties — description of the graphics figure entity properties
  • seteventhandler — set an event handler for the current graphic window
  • xgetmouse — get the mouse events and current position
  • xclick — Wait for a mouse click or an event in a graphic window.
Report an issue
<< edit_curv interaction locate >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Mon Feb 12 20:08:39 CET 2018