BIOSCILAB
SCILAB 4.0 PAS-A-PAS
SCILAB 4.0 STEP-BY-STEP

Jacques-Deric Rouault

CNRS / INRIA

Volume 4   LE GRAPHISME
Volume 4   GRAPHISM
4.17   LA SOURIS GRAPHIQUE
4.17
THE GRAPHIC MOUSE

Version 4.0.19 du 23 Décembre 2005 / Version 4.0.19, December 23th 2005
Scilab 3.1 - Scilab 4.0 /  Windows - Linux

4.16       CONTROLE DE L'AFFICHAGE  / CONTROLING DISPLAY
ALLER A L'INDEX GENERAL / GO TO THE GENERAL INDEX
ALLER A LA TABLE GENERALE / GO TO THE GENERAL TABLE
4.18       LES CARACTERISTIQUES GRAPHIQUES  / GRAPHIC CHARACTERISTICS

4.17.01   Introduction  / Introduction
4.17.10   xclick (P1)
4.17.11   xclick (F2)
4.17.12   xclick (F3)
4.17.13   xclick (F4)
4.17.20   xgetmouse (P1)
4.17.21   xgetmouse (F2)
4.17.22   xgetmouse (F3)
4.17.23   xgetmouse (F4)
4.17.24   xgetmouse (F5)
4.17.25   xgetmouse (F6)
4.17.30   setevenhandler
4.17.40   locate (F1)
4.17.41   locate (F2)
4.17.42   locate (F3)
4.17.98   Mon point de vue  / My viewpoint

4.17.01   Introduction  / Introduction

Graphic mouse
Mouse
Souris graphique

L'usage de la souris dans des fenetres graphiques permet à l'utilisateur de controler directement le déroulement du programme.
The use of the mouse in graphic windows allows user to directly control the program running.

4.17.10   xclick (P1)

xclick (P1, Première forme, First form)

La procédure xclick (ou fonction xclick de première forme) interrompt l'exécution du programme jusqu'à ce que l'utilisateur clique sur la souris.
The procedure xclick (or function xclick of the first form) stops the program running until the user clicks on the mouse.

//  Program Spas41710A
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.17.10A");
hf = scf (1);
hf.figure_name = "4.17.10A";
xclick;
disp ("Fin/end");

Télécharger le fichier / Download the file Spas41710A.sce

Le programme affiche 4.17.10A et ouvre une fenetre graphique.
The program displays 4.17.10A and opens a graphic window.



Déplacer la souris dans la fenetre graphique et cliquer sur la souris.
Move the mouse into the graphic window and clic on the mouse.



La fonction xclick répond également à la frappe d'une touche du clavier.

The function xclick also responds to the strike of a key on the keyboard.

4.17.11   xclick (F2)

xclick (F2 Seconde forme, Second form)

La fonction xclick de seconde forme interrompt l'exécution du programme jusqu'à ce que l'utilisateur clique sur la souris.
The function xclick of the second form stops the program running until the user clicks on the mouse.

La fonction xclick retourne 3 nombres : le numéro du bouton utilisé (0 ou 2 : Voir 4.17.22   xgetmouse (F3))  ou de la touche pressée (Voir 4.17.23   xgetmouse (F4)), et les positions x et y du curseur de la souris dans le repère de la fenetre graphique.
The function xclick returns 3 numbers : the rank of the button used (0 or 2: see 4.17.22   xgetmouse (F3)) or of the key striked (See 4.17.23   xgetmouse (F4)), and the places x and y of the mouse cursor in the system of axes of the graphic window.

//  Program Spas41711A
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.17.11A");
hf = scf (1);
hf.figure_name = "4.17.11A";
ha = gca ();
ha.axes_visible="on";
ha.grid = [2, 3];
[nb, x, y] = xclick (),

Télécharger le fichier / Download the file Spas41711A.sce





La fonction xclick répond également à la frappe d'une touche du clavier. Si on frappe la touche <a> au lieu de cliquer la souris, on a la valeur 97 (code ASCII du caractère a)

The function xclick also responds to the strike of a key on the keyboard. If the user strikes the key <a> instead of clicking the mouse, nb takes the value 97 (ASCII code of character a).



Quand plusieurs fenetres graphiques sont ouvertes, xclick se refere à la fenetre courante. Si on clique sur une autre fenetre graphique, celle-ci devient la fenetre active, mais cela ne modifie pas le fenetre courante.
When several graphic windows are open, xclick works only in the current window. If the click is done in another graphic window, it becomes the active window, but this does not modify the current window.

//  Program Spas41711B
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.17.11B");
hf1 = scf (1);
hf1.figure_name = "4.17.11B1";
ha1 = gca ();
ha1.axes_visible="on";
ha1.grid = [2, 3];

hf2 = scf (2);
hf2.figure_name = "4.17.11B2";
ha2 = gca ();
ha2.axes_visible="on";
ha2.grid = [4, 5];
[nb, x, y] = xclick (),

Télécharger le fichier / Download the file Spas41711B.sce

Ce programme créée deux fenetres graphiques hf1 et hf2. La fenetre courante et active est hf2. Si on clique sur hf1, celle-ci devient active et se place devant la fenetre courante hf2. Le programme ne continue que si on clique sur la fenetre courante hf2.
This program creates two graphic windows hf1 and hf2. The current and active window is hf2. It the click is done on hf1, this window becomes active and is displayed in front of the current window hf2. The program only comes on if the click is done on the current window hf2.

4.17.12   xclick (F3)

xclick (F3 Troisième forme, Third form)

La fonction xclick de troisième forme retourne 5 valeurs dont le numéro de la fenetre graphique.
The function xclick of the third form also returns 5 values with the number of the graphic window..

//  Program Spas41712A
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.17.12A");
hf1 = scf (1);
hf1.figure_name = "4.17.12A1";
ha1 = gca ();
ha1.axes_visible="on";
ha1.grid = [2, 3];

hf2 = scf (2);
hf2.figure_name = "4.17.12A2";
ha2 = gca ();
ha2.axes_visible="on";
ha2.grid = [4, 5];
[nb, x, y, nf, nn] = xclick (),

Télécharger le fichier / Download the file Spas41712A.sce






La valeur nf=1 indique que la souris a été activée sur la première fenetre graphique.
The value nf=1 indicates that the mouse was activated on the first graphic window.

La 5e valeur retournée nn est un caractère correspondant au callback de menu (???).
Thefifth value returned nn is a character corresponding to the menu callback (???)..

4.17.13   xclick (F4)

xclick (F4 Quatrième forme, Fourth form)

La fonction xclick de quatrième forme introduit un argument entier quelconque (flag). Seule sa présence est signifiante. Dans ce cas, la mémoire tampon n'est pas vidée, et la fonction xclick reprend les actions antérieures effectuées par l'utilisateur sur la souris.
The function xclick of the fourth form introduces an integer argument (flag). Ifs value has no meaning, and only its presence is significant. In this case, the buffer memory is not emptyied, and the function xclick takes the previous actions performed by the user on the mouse.

//  Program Spas41713A
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.17.13A");
hf = scf (1);
hf.figure_name = "4.17.13A";
ha = gca ();
ha.axes_visible="on";
ha.grid = [2, 3];
[nb, x, y] = xclick (0);

Télécharger le fichier / Download the file Spas41713A.sce

NB : Ce programme ne fait rien ?
NOTE: this program makes nothing ?
.

4.17.20   xgetmouse (P1)

xgetmouse (P1 Première forme, First form)

La procédure xgetmousede première forme interrompt l'exécution du programme jusqu'à ce que l'utilisateur déplace la souris dans la fenetre graphique ou frappe une touche du clavier.
The procedure xgetmouse of the first form stops the program running until the user moves the mouse into the graphic window or strikes a key.

//  Program Spas41720A
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.17.20A");
hf = scf (1);
hf.figure_name = "4.17.20A";
xgetmouse,
disp ("Fin/end");

Télécharger le fichier / Download the file Spas41720A.sce





Déplacer la souris dans la fenetre graphique.
Move the mouse into the graphic window.

4.17.21   xgetmouse (F2)

xgetmouse (F2 Seconde forme, Second form)

La fonction xgetmouse de seconde forme interrompt l'exécution du programme jusqu'à ce que l'utilisateur clique la souris dans la fenetre graphique ou frappe une touche du clavier.
The function xgetmouse of second form stops the program running until the user clicks on the mouse into the graphic window or strikes a key.

La fonction xgetmouse de seconde forme a en argument d'entrée un vecteur de deux booléens.
The function xgetmouse of second form has one argument : a vector with two booleans.

La fonction xgetmouse retourne la position x et y de la souris dans le repere de la fenetre graphique et le code d'événement.
The function xgetmouse returns the place x and y of the mouse in the system of axes of the graphic window and the code of event.

Si le premier des deux booléens est %F et le second %F,  le programme repart dès qu'un des boutons de la souris a été enfoncé.
If the first of the two booleans is %F and the second one is %F, the program restarts as soon as one of the buttons of the mouse is pressed.

//  Program Spas41721A
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.17.21A");
hf = scf (1);
hf.figure_name = "4.17.21A";
ha = gca ();
ha.axes_visible="on";
ha.grid = [2, 3];
v = xgetmouse ([%F, %F]),

Télécharger le fichier / Download the file Spas41721A.sce

Le programme repart quand on clique la souris dans la fenetre graphique.
The program restarts when the user clicks the mouse in graphic window.



Le code d'événement prend les valeurs suivantes :
The code of event takes the following values.

//  Program Spas41721B
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.17.21B");
hf = scf (1);
hf.figure_name = "4.17.21B";
ha = gca ();
ha.axes_visible="on";
ha.grid = [2, 3];
for i = 1:10 do
  v = xgetmouse ([%F, %F]),
end;
delete (hf);

Télécharger le fichier / Download the file Spas41721B.sce

-100
La fenetre graphique a été fermée
The graphic window is closed
0
Le bouton principal (gauche) a été enfoncé.
The main button (left) is pressed
1
Le bouton central (molette) a été enfoncé.
The central button (toothed wheel) is pressed
2
Le bouton secondaire (droit) a été enfoncé.
The secondary button (right) is pressed
3
Click rapide du bouton principal (gauche)
Quick click on the main button (left)
4
Click rapide du bouton central (molette)
Quick click on the central button (toothed wheel)
5
Click rapide du bouton secondaire (droit)
Quick click on the secondary button (right)
10
Double click du bouton principal (gauche)
Double-click on the main button (left)
11
Double click du bouton central (molette)
Double-click on the central button (toothed wheel)
12
Double click du bouton secondaire (droit)
Double-click on the secondary button (right)

4.17.22   xgetmouse (F3)

xgetmouse (F3 Troisième forme, Third form)

La fonction xgetmouse de troisième forme interrompt l'exécution du programme jusqu'à ce que l'utilisateur déplace ou clique la souris dans la fenetre graphique ou frappe une touche du clavier.
The function xgetmouse of third form stops the program running until the user moves or clicks on the mouse into the graphic window or strikes a key.

La fonction xgetmouse de troisième forme a en argument d'entrée un vecteur de deux booléens.
The function xgetmouse of third form has one argument : a vector with two booleans.

La fonction xgetmouse retourne la position x et y de la souris dans le repere de la fenetre graphique et le code d'événement.
The function xgetmouse returns the place x and y of the mouse in the system of axes of the graphic window and the code of event.

Si le premier des deux booléens est %T et le second %F, le programme repart dès que la souris a été déplacée dans la fenetre graphique (code d'événement -1).
If the first of the two booleans is %T and the second one %F, the program restarts as soon as the mouse is moved in the graphic window (event code -1).

//  Program Spas41722A
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.17.22A");
hf = scf (1);
hf.figure_name = "4.17.22A";
ha = gca ();
ha.axes_visible="on";
ha.grid = [2, 3];
v = xgetmouse ([%T, %F]),

Télécharger le fichier / Download the file Spas41722A.sce







La fonction xgetmouse retourne la position x et y de la souris dans le repere de la fenetre graphique au moment du clic et le code d'événement.
The function xgetmouse returns the place x and y of the mouse in the system of axes of the graphic window when the click was done and the code of event.

Le code d'événement prend les valeurs suivantes :
The code of event takes the following values.

//  Program Spas41722B
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.17.22B");
lines (0);
hf = scf (1);
hf.figure_name = "4.17.22B";
ha = gca ();
ha.axes_visible="on";
ha.grid = [2, 3];
for i=1:100 do
  v = xgetmouse ([%T, %F]),
end;

Télécharger le fichier / Download the file Spas41722B.sce

-100
La fenetre graphique a été fermée
The graphic window is closed
-1
Déplacement de la souris
Moving the mouse
0
Le bouton principal (gauche) a été enfoncé.
The main button (left) is pressed
1
Le bouton central (molette) a été enfoncé.
The central button (toothed wheel) is pressed
2
Le bouton secondaire (droit) a été enfoncé.
The secondary button (right) is pressed
3
Click rapide du bouton principal (gauche)
Quick click on the main button (left)
4
Click rapide du bouton central (molette)
Quick click on the central button (toothed wheel)
5
Click rapide du bouton secondaire (droit)
Quick click on the secondary button (right)
10
Double click du bouton principal (gauche)
Double-click on the main button (left)
11
Double click du bouton central (molette)
Double-click on the central button (toothed wheel)
12
Double click du bouton secondaire (droit)
Double-click on the secondary button (right)

4.17.23   xgetmouse (F4)

xgetmouse (F4 Quatrième forme, Fourth form)

La fonction xgetmouse de quatrième forme est conçue pour être utilisée dans une boucle infinie. If faut alors prévoir un test de sortie de boucle basé sur les valeurs de la position de la souris et/ou du code événement.
The function xgetmouse of the fourth form is designed to be used in an infinite loop. Then a test of loop exist has to be performed, based upon the mouse location and/or the event code.

La fonction xgetmouse de quatrième forme a en argument d'entrée un vecteur de deux booléens.
The function xgetmouse of fourth form has one argument : a vector with two booleans.

La fonction xgetmouse retourne la position x et y de la souris dans le repere de la fenetre graphique et le code d'événement.
The function xgetmouse returns the place x and y of the mouse in the system of axes of the graphic window and the code of event.

Si le second des deux booléens est %T , le programme détecte si un bouton de la souris est pressé ou relaché
If the second of the two booleans is %T , the program detects if a button of the mouse is pressed or released.

//  Program Spas41723A
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.17.23A");
lines (0);
hf = scf (1);
hf.figure_name = "4.17.23A";
ha = gca ();
ha.axes_visible="on";
ha.grid = [2, 3];
xrects ([0; 0.1; 0.1; 0.1], 5);
while 1==1 do
  v = xgetmouse ([%T, %T]),
  if (v(1)>0) & (v(1)<0.1) & (v(2)>0) & (v(2)<0.1) then break; end;
end;

Télécharger le fichier / Download the file Spas41723A.sce

Le programme sort de la boucle infinie quand la souris entre dans la zone rouge.
The program exits the infinite loop when the mouse enters the red area.





-100
La fenetre graphique a été fermée
The graphic window is closed
-5
Le bouton secondaire (droit) a été relaché.
The secondary button (right) is released
-4
Le bouton central (molette) a été relaché.
The central button (toothed wheel) is released
-3
Le bouton principal (gauche) a été relaché.
The main button (left) is released
-1
Déplacement de la souris
Moving the mouse
0
Le bouton principal (gauche) a été enfoncé.
The main button (left) is pressed
1
Le bouton central (molette) a été enfoncé.
The central button (toothed wheel) is pressed
2
Le bouton secondaire (droit) a été enfoncé.
The secondary button (right) is pressed
3
Click rapide du bouton principal (gauche)
Quick click on the main button (left)
4
Click rapide du bouton central (molette)
Quick click on the central button (toothed wheel)
5
Click rapide du bouton secondaire (droit)
Quick click on the secondary button (right)
10
Double click du bouton principal (gauche)
Double-click on the main button (left)
11
Double click du bouton central (molette)
Double-click on the central button (toothed wheel)
12
Double click du bouton secondaire (droit)
Double-click on the secondary button (right)

4.17.24   xgetmouse (F5)

Clavier (xgetmouse, lecture)
Keyboard (xgetmouse, reading)
xgetmouse (F5 Cinquième forme, Fifth form)

La fonction xgetmouse permet aussi de lire le clavier, indépendement de la position de la souris par rapport à la fenêtre graphique courante.
The function xgetmouse also reads the keyboard, independently from the location or the mouse in regard to the active graphic window..

Si le second des deux booléens est %T, la fonction retourne un code positif quand une touche est enfoncée et un code négatif  quand elle est  relachée.
If the second of the two booleans is %T, the function returns a positive code when it is pressed and a negative  one when it is released.

//  Program Spas41724A
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.17.24A");
lines (0);
hf = scf (1);
hf.figure_name = "4.17.24A";
ha = gca ();
ha.axes_visible="on";
ha.grid = [2, 3];
xrects ([0; 0.1; 0.1; 0.1], 5);
while 1==1 do
  v = xgetmouse (0,[%F, %T]),
  if (v(1)>0) & (v(1)<0.1) & (v(2)>0) & (v(2)<0.1) then break; end;
end;
delete (hf);

Télécharger le fichier / Download the file Spas41724A.sce

On tape la touche <a> (code ASCII 97). Pour arreter le programme, cliquer dans le rectangle rouge.
The key <a> (Ascii code 97) is striked. Click in the red rectangle to stop the program.

NB : sous Linux, le clavier n'est pas reconnu si le pavé numérique est activé (BUG).
NOTE: under Linux, the keyboard is not recognized if the numerical keypad is activated (BUG)..



Sous Scilab 3.1 / Under Scilab 3.1

-1032..-1122
Relache de CTRL + de la touche du clavier donnant le code Ascii
Release of CTRL  + the keyboard key corrresponding to the Ascii code.
-975
Relache de ALTGR + la touche ç^
Release of ALTGR + the key ç^
-968
Relache de ALTGR + la touche @
Release of ALTGR + the key @
-224, -231..-233, -249 Relache de SHIFT + la touche à ç è é ù
Release of SHIFT + the key à ç è é ù
-100
La fenetre graphique a été fermée ou relache de la touche <d>
The graphic window is closed or release of the key <d>
-33..-122     
Relache de la touche du clavier donnant le code Ascii
Release of the keyboard key corrresponding to the Ascii code.
-32
Relache de la touche espace ou à
Release of the key space or à
-27
Relache de la touche Echap
Release of the key Escape
-23..25
Relache des touches é è ç
Release of the keys é è ç
-13
Relache de la touche Entrée
Release of the key Enter
-9
Relache de la touche Tabulation
Release of the key Tab
-8
Relache de la touche <--
Release== of the key Backspace
-7
Relache de la touche ù
Release of the key ù
7
Frappe de la touche ù
Strike of the key ù
8
Frappe de la touche <--
Strike of the key Backspace
9
Frappe de la touche Tabulation
Strike of the key Tab
13
Frappe de la touche Entrée
Strike of the key Enter
23..25
Frappe des touches é è ç
Strike of the keys é è ç
27
Frappe de la touche Echap
Strike of the key Esc
32
Frappe de la touche espace ou à
Strike of the key space or à
33..122
Frappe de la touche du clavier donnant le code Ascii
Strike of the keyboard key corrresponding to the Ascii code.
224, 231..233, 249
Frappe de SHIFT + la touche à ç è é ù
Strike of SHIFT + the key à ç è é ù
968
Frappe de ALTGR + la touche @
Strike of ALTGR + the key @
975
Frappe de ALTGR + la touche ç^
Strike of ALTGR + the key ç^
1008..1122
Frappe de CTRL + de la touche du clavier donnant le code Ascii
Strike of CTRL + the keyboard key corrresponding to the Ascii code.

With Scilab 4.0 sous Windows / With Scilab 4.0 under Windows

0
Frappe, relache de la touche Impr écran
Strike, relaesa of the key Screen Print
13, -13
Frappe, relache de la touche Entrée
Strike, release of the key Enter
32, -32
Frappe, relache de la touche espace
Strike, relaesa of the key space
33..122
Frappe, relache de la touche du clavier donnant le code Ascii
Strike, release of the keyboard key corrresponding to the Ascii code.
163, -163
Frappe, relache de la touche £
Strike, release of the key £
167, -167
Frappe, relache de la touche §
Strike, release of the key §
176, -176
Frappe, relache de la touche °
Strike, release of the key °
178, -178
Frappe, relache de la touche ²
Strike, release of the key ²
181, -181
Frappe, relache de la touche µ
Strike, release of the key µ
224, -224
Frappe, relache de la touche à
Strike, release of the key à
231, -231
Frappe, relache de la touche ç
Strike, release of the key ç
232, -232
Frappe, relache de la touche è
Strike, release of the key è
233, -233
Frappe, relache de la touche é
Strike, release of the key é
249, -249
Frappe, relache de la touche ù
Strike, release of the key ù
1000, -1000
Frappe, relache de la touche <Ctrl><à>
Strike, release of the key <Ctrl><à>
1001..1126
-1026...-1001
Frappe, relache de CTRL + de la touche du clavier A..Z donnant le code Ascii
Strike, release of CTRL + the keyboard key A..Z corrresponding to the Ascii code.
1035, -1035
Frappe, relache de la touche #
Strike, release of the key #
1064, -1064
Frappe, relache de la touche @
Strike, release of the key @
1091, -1091
Frappe, relache de la touche [
Strike, release of the key [
1092, -1092
Frappe, relache de la touche \
Strike, release of the key \
1093, -1093
Frappe, relache de la touche ]
Strike, release of the key ]
1094, -1094
Frappe, relache de la touche ^ (<AltGr><ç>)
Strike, release of the key ^ (<AltGr><ç>)
1096, -25672
25672, -1096
Frappe, relache de la touche `
Strike, release of the key  `
1123, -1123
Frappe, relache de la touche {
Strike, release of the key {
1124, -1124
Frappe, relache de la touche |
Strike, release of the key |
1125, -1125
Frappe, relache de la touche }
Strike, release of the key }
1126, -33382
33382, -1126
Frappe, relache de la touche ~
Strike, release of the key ~
65289, -65289
Frappe, relache des touches Pause
Strike, release of the key Pause
65299, -65299
Frappe, relache de la  touche <--, tabulation
Strike, release of the keys BackSpace, Tab
65300, -65300
Frappe, relache des touches Pause
Strike, release of the key Pause
65307, -65307
Frappe, relache de la touche Arret défill
Strike, release of the key Scrolling
65360, -65360
Frappe, relache de la touche Home (fléche en haut à gauche)
Strike, release of the key Home 
65361, -65361
Frappe, relache de la touche déplacement à gauche
Strike, release of the key Move left
65362, -65362
Frappe, relache de la touche déplacement en haut
Strike, release of the key Move up
65363, -65363
Frappe, relache de la touche déplacement à droite
Strike, release of the key Move right
65364, -65364
Frappe, relache de la touche déplacement en bas
Strike, release of the key Move down
65365, -65365
Frappe, relache de la touche déplacement tout en haut
Strike, release of the key Move top
65366, -65366
Frappe, relache de la touche déplacement tout en bas
Strike, release of the key Move bottom
65367, -65367
Frappe, relache de la touche Fin
Strike, release of the key End
65379, -65379
Frappe, relache de la touche Inser
Strike, release of the key Insert
65408, -65408
Frappe, relache de la touche 5 du pavé numérique désactivé
Strike, release of the key 5 of the numeric keypad desactivated
65470..65481
-65481..-65470
Frappe, relache des touches <F1> ... <F12>
Strike, release of the keys <F1> ... <F12>
65538, -65535
Frappe, relache de la touche Suppr
Strike, release of the key Del

With Scilab 4.0 sous Linux, le compotement peut être différent. Le clavier numérique doit être dévérouillé, sinon le clavier n'est pas reconnu. Sous Linux, la souris doit être dans la fenetre graphique, alors que sous Windows, elle peut être n'importe où. Sous Linux, les touches en dehors du clavier central et les touches spéciales ne sont pas reconnus qhand elles sont relachées. Voir BUG 1663.
With Scilab 4.0 under Windows, the behaviour can be different.
The numerical lock must be off, else keyboard is not recognized. Under Windows, le whole screen is admitted, under Linux, only when the mouse is into the graphic window. Under Linux, the extra central keys and the special keys of the central keyboard are not recognized when released. See BUG 1663.

Si le second des deux booléens est %F, la fonction retourne un code positif quand la touche est relachée.
If the second of the two booleans is %F, the function returns a positive code when the key is released.

//  Program Spas41724B
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.17.24B");
lines (0);
hf = scf (1);
hf.figure_name = "4.17.24B";
ha = gca ();
ha.axes_visible="on";
ha.grid = [2, 3];
xrects ([0; 0.1; 0.1; 0.1],5);
while 1==1 do
  v = xgetmouse (0,[%F, %F]),
  if (v(1)>0) & (v(1)<0.1) & (v(2)>0) & (v(2)<0.1) then break; end;
end;
delete (hf);

Télécharger le fichier / Download the file Spas41724B.sce

On tape la touche <a> (code ASCII 97). Pour arreter le programme, cliquer dans le rectangle rouge.
The key <a> (Ascii code 97) is striked. Click in the red rectangle to stop the program.

NB : sous Linux, le clavier n'est pas reconnu si le pavé numérique est activé (BUG).
NOTE: under Linux, the keyboard is not recognized if the numerical keypad is activated (BUG)..



Avec Scilab 3.1, si on tape la touche <d>, le code de relachement est -100, qui est alors interprété comme si la fenetre graphique avit été fermée entretemps. BUG 1459
With Scilab 3.1, when entering the letter <d>, the code of release of the key is -100, then it is interpreted as if the graphic window has been closed. BUG 1459

4.17.25   xgetmouse (F6)

xgetmouse (F6 Sixième forme, Sixth form)

La fonction xgetmouse de sixième forme a deux arguments d'entrée : un entier et un vecteur de deux booléens.
The function xgetmouse of the sixth form has two arguments : an integer and a vector with two booleans.

Seule la présence de l'entier est signifiante. Dans ce cas, la mémoire tampon n'est pas vidée, et la fonction xgetmouse reprend les actions antérieures effectuées par l'utilisateur sur la souris ou le clavier.
The value of the integer has no meaning, and only its presence is significant. In this case, the buffer memory is not emptyied, and the function xgetmouse takes the previous actions performed by the user on the mouse or the keyboard.

//  Program Spas41725A
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.17.25A");
lines (0);
hf = scf (1);
hf.figure_name = "4.17.25A";
ha = gca ();
ha.axes_visible="on";
ha.grid = [2, 3];
xrects ([0; 0.1; 0.1; 0.1],5);
while 1==1 do
  v = xgetmouse (0,[%F, %F]),
  if (v(1)>0) & (v(1)<0.1) & (v(2)>0) & (v(2)<0.1) then break; end;
end;
delete (hf);

Télécharger le fichier / Download the file Spas41724B.sce

Le programme sort de la boucle infinie quand on clique la souris dans la zone rouge.
The program exits the infinite loop when the mouse is clicked in the red area..

Problème d'arret ?

problem of stop and exit ?

4.17.30   setevenhandler

seteventhandler

La procédure setevenhandler permet d'appeler automatiquement une fonction dédiée dès qu'un événement souris ou clavier a été détecté.
The procedure seteventhandler allows to automatically call a devoted function as soon as an event mouse or keyboard is detected.

On commence par construire une fonction avec 4 arguments entiers win, mx, my et event.
First, a function with 4 integer arguments win, mx, my and event has to be built.

//  Program Spas41730A
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.17.30A");
//--------------------------------------------
function manage_event (win,mx,my,event);
  mprintf ("win = %d - mx = %f -  my = %f event = %d\n", win, mx, my, event);
endfunction;
//--------------------------------------------

manage_event (5, 2.1, 3.2, 10);

Télécharger le fichier / Download the file Spas41730A.sce



La variable win donne le numéro de la fenetre graphique, mx et my la position de la souris en pixels et event le code de l'événement.
The variable win contains the number of the window, mx and my the location  in pixels of the mouse and event the code of event.

On construit ensuite le programme principal avec la procédure seteventhandler qui appelle la fonction précédemment construite.
Then the main program is built with the procedure seteventhandler which calls the previously built function.

La procédure seteventhandler ("") supprime le lien précédemment créé.
The procedure seteventhandler ("")  suppresses the link previously created.

//  Program Spas41730B
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.17.30B");
//--------------------------------------------
function manage_event (win,mx,my,event);
  [x,y]=xchange(mx,my,'i2f');
  mprintf ("win = %d - x = %f -  y = %f event = %d\n", win, x, y, event);
endfunction;
//--------------------------------------------

global finend;
lines (0);
hf = scf (1);
hf.figure_name = "4.17.30B";
ha = gca ();
ha.axes_visible="on";
ha.grid = [2, 3];
xrects ([0; 0.1; 0.1; 0.1],5);
seteventhandler ("manage_event");
seteventhandler ("");
delete (hf);

Télécharger le fichier / Download the file Spas41730B.sce

NB : Ce programme s'exécute trop rapidement pour que l'utilisateur ait le temps de créer un événement.
NOTE: This program runs too quickly, so the user has no time enough to create an event.

//  Program Spas41730C
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.17.30C");
//--------------------------------------------
function manage_event (win,mx,my,event);
  global finend;
  [x,y]=xchange(mx,my,'i2f');
  mprintf ("win = %d - x = %f -  y = %f event = %d\n", win, x, y, event);
  if (x>0) & (x<0.1) & (y>0) & (y<0.1) then
    finend=%T;
    return;
  else
    finend=%F;
    return;
    end;
endfunction;
//--------------------------------------------

global finend;
lines (0);
hf = scf (1);
hf.figure_name = "4.17.30C";
ha = gca ();
ha.axes_visible="on";
ha.grid = [2, 3];
xrects ([0; 0.1; 0.1; 0.1],5);
while 1==1 do
  seteventhandler ("manage_event");
  finend,
  if finend then abort; end;
end;
seteventhandler ("");
delete (hf);

Télécharger le fichier / Download the file Spas41730C.sce



NB : Ce programme ne permet pas de sortir de la fonction.
NOTE: This program does not allow to exit the function.

4.17.40   locate (P1)

locate (F1 Première forme, First form)

La fonction locate de première forme retourne les coordonnées des points cliqués dans la fenetre graphique active.
The function locate of the first form returns the coordinates of the points clicked in the active graphic window.

//  Program Spas41740A
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.17.40A");
hf = scf (1);
hf.figure_name = "4.17.40A";
ha = gca ();
ha.axes_visible="on";
ha.grid = [2, 3];
points = locate (),
delete (hf);

Télécharger le fichier / Download the file Spas41740A.sce

On clique avec le bouton gauche. Pour arreter, cliquer longuement le bouton droit (ce point n'est pas intégré).
Click with the left button. To stop, click a long time on the right button (this point is not integrated).
.



On clique avec le bouton gauche sur les 4  points
(0.1;0.1), (0.2;0.2), (0.3;0.3) et (0.4;0.4). Pour arreter, cliquer longuement sur le bouton droit .
Click with the left button on the 4 points (0.1;0.1), (0.2;0.2), (0.3;0.3) and (0.4;0.4) . To stop, click a long time on the right button.
.



NB : La fonction locate n'est pas compatible avec les représentation en 3 dimensions.
NOTE: The function locate is not compatible with 3-dimension representations.

4.17.41   locate (F2)

locate (F2 Seconde forme, Second form)

Dans la fonction locate de seconde forme on donne en entrée le nombre de points à saisir et un drapeau entier (1) pour marquer les points saisis par une croix X.
In the function locate of the second form, the number of points to be catch and an integer flag (1) to visualize the catch points by a cross X are provided.
 

//  Program Spas41741A
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.17.41A");
hf = scf (1);
hf.figure_name = "4.17.41A";
ha = gca ();
ha.axes_visible="on";
ha.box = "on";
points = locate (4,1),
xpause (5000000);
delete (hf);

Télécharger le fichier / Download the file Spas41741A.sce





Avec Scilab 3.0, la fonction locate crée un handle Polyline. Ce n'est plus le cas avec les versions postérieures.
The function locate creates a handle Polyline. This is no more the case with the posterior versions.
 

//  Program Spas41741B
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.17.41B");
hf = scf (1);
hf.figure_name = "4.17.41B";
ha = gca ();
ha.axes_visible="on";
ha.box = "on";
points = locate (4,1),
hh = gce (),
delete (hf);

Télécharger le fichier / Download the file Spas41741B.sce





Si le drapeau entier est différent de 1, les points saisis ne sont pas marqués.
If the integer flag is different from 1, the catch points are not marked.
 

//  Program Spas41741C
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.17.41C");
hf = scf (1);
hf.figure_name = "4.17.41C";
ha = gca ();
ha.axes_visible="on";
ha.box = "on";
points = locate (4,0),
xpause (5000000);
delete (hf);

Télécharger le fichier / Download the file Spas41741C.sce

4.17.42   locate (F3)

locate (F3 Troisième forme, Third form)

Dans la fonction locate de troisième forme on donne en entrée un nombre négatif de points à saisir. Les points sont saisis avec le bouton gauche jusqu'à ce que l'utilisateur clique (longuement ?) sur le bouton droit.
In the function locate of the third form, a negative number of points to be catch is provided. The points are catched with the left button until the user clicks (a long time ?) on the right button.
 

//  Program Spas41742A
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.17.42A");
hf = scf (1);
hf.figure_name = "4.17.42A";
ha = gca ();
ha.axes_visible="on";
ha.box = "on";
points = locate (-1,1),
xpause (5000000);
delete (hf);

Télécharger le fichier / Download the file Spas41742A.sce





4.17.98   Mon point de vue  / My viewpoint

La souris est programmée pour les droitiers et ne s'adapte pas au contexte du système d'exploitation (souris main droite ou main gauche).
The mouse is programmed for right handed people and is not adapted to the context of the operating system (right or left hand mouse).

4.17.99   Zones d'ombre  / Shadowy areas

Signification du callback de menu ?

Si on tape la touche <d>, le code de relachement est -100, qui est alors interprété comme si la fenetre graphique avit été fermée entretemps. BUG 1459
When entering the letter <d>, the code of release of the key is -100, then it is interpreted as if the graphic window has been closed. BUG 1459

Mise en oeuvre de seteventhandler ???

4.17       CONTROLE DE L'AFFICHAGE  / CONTROLING DISPLAY
ALLER A L'INDEX GENERAL / GO TO THE GENERAL INDEX
ALLER A LA TABLE GENERALE / GO TO THE GENERAL TABLE
4.18       LES CARACTERISTIQUES GRAPHIQUES  / GRAPHIC CHARACTERISTICS