xgetmouse — get the mouse events and current position
[rep [,win]]=xgetmouse([sel])
boolean vector [getmotion, getrelease]. default
value is [%t, %f]
vector of size 3, [x,y,ibutton].
number of the figure where the event occurred.
If the mouse pointer is located in the current graphics window, xgetmouse returns
in rep the current pointer position (x,y) and the value ibutton.
The ibutton value indicates the 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
pointer has moved
key with ascii code ascii(ibutton) has been pressed
key with ascii code ascii(-ibutton) has been released
key with ascii code ascii(ibutton-1000) has been pressed while CTRL key pressed
graphic window has been closed
WARNING: In previous versions of Scilab (<5.0), the user could give a flag to precise if the mouse click event queue had to be cleared when entering xgetmouse. This option has been removed in Scilab 5.1.
// rectangle selection
clf(); // erase/create window
a=gca();a.data_bounds=[0 0;100 100];//set user coordinates
xtitle(" drawing a rectangle ") //add a title
xselect(); //put the window on the top
[b,xc,yc]=xclick(); //get a point
xrect(xc,yc,0,0) //draw a rectangle entity
r=gce();// the handle of the rectangle
rep=[xc,yc,-1];first=%f;
while rep(3)==-1 do // mouse just moving ...
rep=xgetmouse();
xc1=rep(1);yc1=rep(2);
ox=mini(xc,xc1);
oy=maxi(yc,yc1);
w=abs(xc-xc1);h=abs(yc-yc1);
r.data=[ox,oy,w,h]; //change the retangle origin, width an height
first=%f;
end