Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.3.0 - Français

Change language to:
English - 日本語 - 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

Manuel Scilab >> Bibliothèque graphique > interaction > xgetmouse

xgetmouse

get the mouse events and current position

Calling Sequence

[rep [,win]]=xgetmouse([sel])

Arguments

sel

boolean vector [getmotion, getrelease]. default value is [%t, %f]

rep

vector of size 3, [x,y,ibutton].

win

number of the figure where the event occurred.

Description

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:

ibutton==0

Left mouse button has been pressed

ibutton==1

Middle mouse button has been pressed

ibutton==2

Right mouse button has been pressed

ibutton==3

Left mouse button has been clicked

ibutton==4

Middle mouse button has been clicked

ibutton==5

Right mouse button has been clicked

ibutton==10

Left mouse button has been double-clicked

ibutton==11

Middle mouse button has been double-clicked

ibutton==12

Right mouse button has been double-clicked

ibutton==-5

Left mouse button has been released

ibutton==-4

Middle mouse button has been released

ibutton==-3

Right mouse button has been released

ibutton==-1

pointer has moved

ibutton > =32

key with ascii code ascii(ibutton) has been pressed

ibutton < =-32

key with ascii code ascii(-ibutton) has been released

ibutton > =1000+32

key with ascii code ascii(ibutton-1000) has been pressed while CTRL key pressed

ibutton==-1000

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.

Examples

//  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
show_window(); //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=min(xc,xc1);
  oy=max(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

Authors

S. Steer

<< seteventhandler interaction pie >>

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:
Wed Jan 26 16:24:15 CET 2011